Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FileNotFoundError: NPM not found. You may need to run reflex init on a clean setup #4839

Open
em-synth opened this issue Feb 18, 2025 · 4 comments
Labels
need repro example Need an example that can be copy/pasted to reproduce the issue immediately

Comments

@em-synth
Copy link

em-synth commented Feb 18, 2025

On a fresh v0.7.0 install the application does not start and fail with the following error

  File "/home/eduardo/.pyenv.../lib/python3.12/site-packages/reflex/utils/prerequisites.py", line 261, in get_package_manager
    raise FileNotFoundError("NPM not found. You may need to run `reflex init`.")
FileNotFoundError: NPM not found. You may need to run `reflex init`.

Break-pointing into the code I can see that here

npm_path = Path(constants.Node.NPM_PATH)
it is looking for the following path

PosixPath('/home/eduardo/.local/share/reflex/fnm/node-versions/v22.11.0/installation/bin/npm')

The only binary I have .local/share/reflex is /home/eduardo/.local/share/reflex/bun/bin/bun. Something is really off and the clean setup is completely unusable for me.

Specifics (please complete the following information):

  • Python Version: 3.10
  • Reflex Version: 0.7.0
  • OS: Linux

Running it with debug loglevel gives back

Debug: Config file: 
'/home/eduardo/.pyenv/versions/app_name/lib/python3.12/site-packages/reflex/con
fig.py'
Debug: Config: app_name='<AppName>' loglevel=<LogLevel.DEFAULT: 'default'> 
frontend_port=3000 frontend_path='' backend_port=8000 
api_url='http://localhost:8000' deploy_url='http://localhost:3000' 
backend_host='0.0.0.0' db_url='sqlite:///reflex.db' async_db_url=None 
redis_url=None telemetry_enabled=True 
bun_path=PosixPath('/home/eduardo/.local/share/reflex/bun/bin/bun') 
static_page_generation_timeout=60 cors_allowed_origins=['*'] 
tailwind={'plugins': ['@tailwindcss/typography']} timeout=120 
next_compression=True react_strict_mode=True frontend_packages=[] 
cp_backend_url='https://cloud-1e140ead-7b27-4248-961b-a58562714ac0.fly.dev' 
cp_web_url='https://cloud.reflex.dev' 
gunicorn_worker_class='uvicorn.workers.UvicornH11Worker' gunicorn_workers=None 
gunicorn_max_requests=100 gunicorn_max_requests_jitter=25 
state_manager_mode=<StateManagerMode.DISK: 'disk'> redis_lock_expiration=10000 
redis_lock_warning_threshold=1000 redis_token_expiration=3600 env_file=None
Debug: Running command: [PosixPath('/home/eduardo/.local/share/reflex/fnm/fnm'),
'--version']
Debug: Running command: ['/home/eduardo/.local/share/reflex/bun/bin/bun', '-v']
Debug: [Reflex 0.6.8 with Python 3.12.5 (PATH: 
/home/eduardo/.pyenv/versions/app_name/bin/python3)]
Debug: [Node None (Expected: 22.11.0) (PATH:None)]
Debug: [FNM None (Expected: 1.35.1) (PATH: 
/home/eduardo/.local/share/reflex/fnm/fnm)]
Debug: [Bun 1.1.29 (Expected: 1.1.29) (PATH: 
/home/eduardo/.local/share/reflex/bun/bin/bun)]
Debug: [OS Linux Ubuntu 22.04.5 LTS]
Debug: Using package installer at: /home/eduardo/.local/share/reflex/bun/bin/bun
@adhami3310
Copy link
Member

Can you include a larger traceback?

@adhami3310 adhami3310 added the need repro example Need an example that can be copy/pasted to reproduce the issue immediately label Feb 19, 2025
@crisonyx
Copy link

crisonyx commented Feb 23, 2025

I am having a very similar issue. I am not using a clean install though. I started the chat app tutorial on 0.6.8 and just today attempted to upgrade to 0.7.0 to see if the issue would be resolved.

Here is my full stack.

The largest difference I see from @em-synth 's is that I have node installed on my host system and he does not. I don't have npm installed on the host.

Here is my full stack trace after deleting the .web folder:

Debug: Config file: '/home/cris/projects/reflex_testing/.venv/lib/python3.13/site-packages/reflex/config.py'
Debug: Config: app_name='reflex_testing' app_module_import=None loglevel=<LogLevel.DEFAULT: 'default'> frontend_port=3000 frontend_path='' backend_port=8000 
api_url='http://localhost:8000' deploy_url='http://localhost:3000' backend_host='0.0.0.0' db_url='sqlite:///reflex.db' async_db_url=None redis_url=None telemetry_enabled=True 
bun_path=PosixPath('/home/cris/.local/share/reflex/bun/bin/bun') static_page_generation_timeout=60 cors_allowed_origins=['*'] tailwind={'plugins': ['@tailwindcss/typography']} 
timeout=120 next_compression=True react_strict_mode=True frontend_packages=[] cp_backend_url='https://cloud-1e140ead-7b27-4248-961b-a58562714ac0.fly.dev' 
cp_web_url='https://cloud.reflex.dev' gunicorn_worker_class='uvicorn.workers.UvicornH11Worker' gunicorn_workers=None gunicorn_max_requests=100 gunicorn_max_requests_jitter=25 
state_manager_mode=<StateManagerMode.DISK: 'disk'> redis_lock_expiration=10000 redis_lock_warning_threshold=1000 redis_token_expiration=3600 env_file=None 
show_built_with_reflex=True is_reflex_cloud=False
Debug: Running command: [PosixPath('/usr/bin/node'), '-v']
Debug: Running command: [PosixPath('/home/cris/.local/share/reflex/fnm/fnm'), '--version']
Debug: Running command: ['/home/cris/.local/share/reflex/bun/bin/bun', '-v']
Debug: [Reflex 0.7.0 with Python 3.13.2 (PATH: /home/cris/projects/reflex_testing/.venv/bin/python3)]
Debug: [Node 23.8.0 (Expected: 22.11.0) (PATH:/usr/bin/node)]
Debug: [FNM 1.35.1 (Expected: 1.35.1) (PATH: /home/cris/.local/share/reflex/fnm/fnm)]
Debug: [Bun 1.2.0 (Expected: 1.2.0) (PATH: /home/cris/.local/share/reflex/bun/bin/bun)]
Debug: [OS Linux EndeavourOS]
Debug: Using package installer at: /home/cris/.local/share/reflex/bun/bin/bun
Debug: Using package executer at: None
Debug: Unzip path: /usr/bin/unzip
──────────────────────────────────────────────────────────────────────────────────── System Info ────────────────────────────────────────────────────────────────────────────────────
Debug: Config file: '/home/cris/projects/reflex_testing/.venv/lib/python3.13/site-packages/reflex/config.py'
Debug: Config: app_name='reflex_testing' app_module_import=None loglevel=<LogLevel.DEFAULT: 'default'> frontend_port=3000 frontend_path='' backend_port=8000 
api_url='http://localhost:8000' deploy_url='http://localhost:3000' backend_host='0.0.0.0' db_url='sqlite:///reflex.db' async_db_url=None redis_url=None telemetry_enabled=True 
bun_path=PosixPath('/home/cris/.local/share/reflex/bun/bin/bun') static_page_generation_timeout=60 cors_allowed_origins=['*'] tailwind={'plugins': ['@tailwindcss/typography']} 
timeout=120 next_compression=True react_strict_mode=True frontend_packages=[] cp_backend_url='https://cloud-1e140ead-7b27-4248-961b-a58562714ac0.fly.dev' 
cp_web_url='https://cloud.reflex.dev' gunicorn_worker_class='uvicorn.workers.UvicornH11Worker' gunicorn_workers=None gunicorn_max_requests=100 gunicorn_max_requests_jitter=25 
state_manager_mode=<StateManagerMode.DISK: 'disk'> redis_lock_expiration=10000 redis_lock_warning_threshold=1000 redis_token_expiration=3600 env_file=None 
show_built_with_reflex=True is_reflex_cloud=False
Debug: Running command: [PosixPath('/usr/bin/node'), '-v']
Debug: Running command: [PosixPath('/home/cris/.local/share/reflex/fnm/fnm'), '--version']
Debug: Running command: ['/home/cris/.local/share/reflex/bun/bin/bun', '-v']
Debug: [Reflex 0.7.0 with Python 3.13.2 (PATH: /home/cris/projects/reflex_testing/.venv/bin/python3)]
Debug: [Node 23.8.0 (Expected: 22.11.0) (PATH:/usr/bin/node)]
Debug: [FNM 1.35.1 (Expected: 1.35.1) (PATH: /home/cris/.local/share/reflex/fnm/fnm)]
Debug: [Bun 1.2.0 (Expected: 1.2.0) (PATH: /home/cris/.local/share/reflex/bun/bin/bun)]
Debug: [OS Linux EndeavourOS]
Debug: Using package installer at: /home/cris/.local/share/reflex/bun/bin/bun
Debug: Using package executer at: None
Debug: Unzip path: /usr/bin/unzip
──────────────────────────────────────────────────────────────────────────── Initializing reflex_testing ────────────────────────────────────────────────────────────────────────────
Debug: Running command: [PosixPath('/usr/bin/node'), '-v']
Debug: Skipping node installation as it is already installed.
Debug: Running command: ['/home/cris/.local/share/reflex/bun/bin/bun', '-v']
Debug: Skipping bun installation as it is already installed.
[11:49:22] Initializing the web directory.                                                                                                                             console.py:160
Debug: Setting project hash to 20556822282059562023970624761690784854.
Debug: Creating .gitignore
Debug: Detected encoding for requirements.txt as ascii.
Debug: requirements.txt already has reflex as dependency.
Success: Initialized reflex_testing
──────────────────────────────────────────────────────────────────────────────── Starting Reflex App ────────────────────────────────────────────────────────────────────────────────
[11:49:29] Compiling: ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━   0%  0/16 0:00:00Debug: Evaluating page: index
Debug: Evaluating page: 404
Debug: [timing] Evaluate Pages (Frontend): 0.04s
Debug: [timing] Auto-memoize StatefulComponents: 0.02s
Debug: [timing] Copy assets: 0.00s
[11:49:29] Compiling: ━━━━━━━━━━━━━━━━━╸━━━━━━━━━━━━━━━━━━━━━━  44%  7/16 0:00:00Debug: [timing] Compile to Javascript: 0.00s
[11:49:29] Compiling: ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 100% 16/16 0:00:00
Debug: Running command: ['/home/cris/.local/share/reflex/bun/bin/bun', 'install']
Debug: Installing base frontend packages
Debug: bun install v1.2.0 (b0c5a765)
Debug: Resolving dependencies
Debug: Resolved, downloaded and extracted [278]
Debug: Saved lockfile
Debug: 
Debug: + [email protected]
Debug: + [email protected]
Debug: + [email protected]
Debug: + @babel/[email protected]
Debug: + @emotion/[email protected]
Debug: + [email protected]
Debug: + [email protected]
Debug: + [email protected]
Debug: + [email protected]
Debug: + [email protected]
Debug: + [email protected]
Debug: + [email protected]
Debug: + [email protected]
Debug: + [email protected]
Debug: + [email protected]
Debug: 
Debug: 170 packages installed [684.00ms]
Debug: Running command: ['/home/cris/.local/share/reflex/bun/bin/bun', 'add', '-d', '[email protected]', '@tailwindcss/typography']
Debug: Installing tailwind
Debug: bun add v1.2.0 (b0c5a765)
Debug: Resolving dependencies
Debug: Resolved, downloaded and extracted [124]
Debug: Saved lockfile
Debug: 
Debug: installed [email protected] with binaries:
Debug:  - tailwind
Debug:  - tailwindcss
Debug: installed @tailwindcss/[email protected]
Debug: 
Debug: 72 packages installed [285.00ms]
Debug: Running command: ['/home/cris/.local/share/reflex/bun/bin/bun', 'add', '[email protected]', '@radix-ui/themes@^3.0.0 && <3.1.5', '[email protected]']
Debug: Installing frontend packages from config and components
Debug: bun add v1.2.0 (b0c5a765)
Debug: Resolving dependencies
Debug: Resolved, downloaded and extracted [18]
Debug: Saved lockfile
Debug: 
Debug: installed [email protected]
Debug: installed @radix-ui/[email protected]
Debug: installed [email protected]
Debug: 
Debug: 64 packages installed [748.00ms]
Debug: [timing] Install Frontend Packages: 1.74s
Debug: [timing] Write to Disk: 0.00s
Traceback (most recent call last):
  File "/home/cris/projects/reflex_testing/.venv/bin/reflex", line 10, in <module>
    sys.exit(cli())
             ~~~^^
  File "/home/cris/projects/reflex_testing/.venv/lib/python3.13/site-packages/typer/main.py", line 340, in __call__
    raise e
  File "/home/cris/projects/reflex_testing/.venv/lib/python3.13/site-packages/typer/main.py", line 323, in __call__
    return get_command(self)(*args, **kwargs)
           ~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^
  File "/home/cris/projects/reflex_testing/.venv/lib/python3.13/site-packages/click/core.py", line 1161, in __call__
    return self.main(*args, **kwargs)
           ~~~~~~~~~^^^^^^^^^^^^^^^^^
  File "/home/cris/projects/reflex_testing/.venv/lib/python3.13/site-packages/typer/core.py", line 743, in main
    return _main(
        self,
    ...<6 lines>...
        **extra,
    )
  File "/home/cris/projects/reflex_testing/.venv/lib/python3.13/site-packages/typer/core.py", line 198, in _main
    rv = self.invoke(ctx)
  File "/home/cris/projects/reflex_testing/.venv/lib/python3.13/site-packages/click/core.py", line 1697, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
                           ~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^
  File "/home/cris/projects/reflex_testing/.venv/lib/python3.13/site-packages/click/core.py", line 1443, in invoke
    return ctx.invoke(self.callback, **ctx.params)
           ~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/cris/projects/reflex_testing/.venv/lib/python3.13/site-packages/click/core.py", line 788, in invoke
    return __callback(*args, **kwargs)
  File "/home/cris/projects/reflex_testing/.venv/lib/python3.13/site-packages/typer/main.py", line 698, in wrapper
    return callback(**use_params)
  File "/home/cris/projects/reflex_testing/.venv/lib/python3.13/site-packages/reflex/reflex.py", line 297, in run
    _run(env, frontend, backend, frontend_port, backend_port, backend_host, loglevel)
    ~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/cris/projects/reflex_testing/.venv/lib/python3.13/site-packages/reflex/reflex.py", line 231, in _run
    setup_frontend(Path.cwd())
    ~~~~~~~~~~~~~~^^^^^^^^^^^^
  File "/home/cris/projects/reflex_testing/.venv/lib/python3.13/site-packages/reflex/utils/build.py", line 239, in setup_frontend
    prerequisites.get_package_manager(),
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^
  File "/home/cris/projects/reflex_testing/.venv/lib/python3.13/site-packages/reflex/utils/prerequisites.py", line 261, in get_package_manager
    raise FileNotFoundError("NPM not found. You may need to run `reflex init`.")
FileNotFoundError: NPM not found. You may need to run `reflex init`.
[11:49:31] Reflex app stopped.                                                     ```

@crisonyx
Copy link

FWIW, the issue is fixed if I install npm on the host. I would not expect to need to going by the docs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
need repro example Need an example that can be copy/pasted to reproduce the issue immediately
Projects
None yet
Development

No branches or pull requests

3 participants