You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
npm --version: 10.2.0 (ran "npm --version" in console at the path of project)
node --version: v18.18.2 (ran "node--version" in console at the path of project)
Description
Trying to follow along the example workflow - specifically the step for installing dependencies
What I Did
>flask vite init Vite source directory and starter content installed in 'vite'.
>flask vite install
Traceback (most recent call last):
File "C:\Users\nicra\Desktop\planetDotPizza\venv\Lib\site-packages\flask_vite\npm.py", line 21, in run
subprocess.run(_args, cwd=self.cwd)
File "C:\Python312\Lib\subprocess.py", line 548, in run
with Popen(*popenargs, **kwargs) as process:
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Python312\Lib\subprocess.py", line 1026, in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
File "C:\Python312\Lib\subprocess.py", line 1538, in _execute_child
hp, ht, pid, tid = _winapi.CreateProcess(executable, args,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
FileNotFoundError: [WinError 2] The system cannot find the file specified
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<frozen runpy>", line 198, in _run_module_as_main
File "<frozen runpy>", line 88, in _run_code
File "C:\Users\nicra\Desktop\planetDotPizza\venv\Scripts\flask.exe\__main__.py", line 7, in <module>
File "C:\Users\nicra\Desktop\planetDotPizza\venv\Lib\site-packages\flask\cli.py", line 1064, in main
cli.main()
File "C:\Users\nicra\Desktop\planetDotPizza\venv\Lib\site-packages\click\core.py", line 1078, in main
rv = self.invoke(ctx)
^^^^^^^^^^^^^^^^
File "C:\Users\nicra\Desktop\planetDotPizza\venv\Lib\site-packages\click\core.py", line 1688, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\nicra\Desktop\planetDotPizza\venv\Lib\site-packages\click\core.py", line 1688, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\nicra\Desktop\planetDotPizza\venv\Lib\site-packages\click\core.py", line 1434, in invoke
return ctx.invoke(self.callback, **ctx.params)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\nicra\Desktop\planetDotPizza\venv\Lib\site-packages\click\core.py", line 783, in invoke
return __callback(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\nicra\Desktop\planetDotPizza\venv\Lib\site-packages\click\decorators.py", line 33, in new_func
return f(get_current_context(), *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\nicra\Desktop\planetDotPizza\venv\Lib\site-packages\flask\cli.py", line 358, in decorator
return __ctx.invoke(f, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\nicra\Desktop\planetDotPizza\venv\Lib\site-packages\click\core.py", line 783, in invoke
return __callback(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\nicra\Desktop\planetDotPizza\venv\Lib\site-packages\flask_vite\cli.py", line 44, in install
npm.run("install")
File "C:\Users\nicra\Desktop\planetDotPizza\venv\Lib\site-packages\flask_vite\npm.py", line 40, in run
raise NPMError(dedent(msg))
flask_vite.npm.NPMError:
An error occurred while running npm.
cwd: C:\Users\nicra\Desktop\planetDotPizza\vite
npm_bin_path: npm
Flask app.py file:
from flask import Flask
from flask_vite import Vite
app = Flask(__name__)
vite = Vite(app)
@app.route('/')
def index():
return "hello world"
if __name__ == "__main__":
app.run()
The text was updated successfully, but these errors were encountered:
Locate the binary for your npm/pnpm version and specify it in the config:
app=Flask(__name__)
# This must be set before calling Vite()app.config[
"VITE_NPM_BIN_PATH"
] ="C:/Users/User/scoop/apps/nvm/current/nodejs/nodejs/pnpm.cmd"vite=Vite(app)
Locate the binary for your npm/pnpm version and specify it in the config:
app=Flask(__name__)
# This must be set before calling Vite()app.config[
"VITE_NPM_BIN_PATH"
] ="C:/Users/User/scoop/apps/nvm/current/nodejs/nodejs/pnpm.cmd"vite=Vite(app)
Thanks for the response. It works.
In my case, reading the vite npm bin path from a .env file somehow always transform the VITE_NPM_BIN_PATH value set before it got to Vite. What worked was setting the path in the code.
.env VITE_NPM_BIN_PATH = 'C:\\Users\\<user>\\AppData\\Roaming\\npm\\pnpm.cmd' print(VITE_NPM_BIN_PATH) === It read it as npm_bin_path: C:\\Users\\<user>\\AppData\\Roaming\ pm\\pnpm.cmd
It truncates "\n" from \npm which brought the error: File "C:\Pythonapps\app\.venv\Lib\site-packages\flask_vite\npm.py", line 46, in run raise NPMError(dedent(msg)) flask_vite.npm.NPMError: An error occurred while running npm. cwd: C:\Pythonapps\app\client npm_bin_path: C:\\Users\\<user>\\AppData\\Roaming\ pm\\pnpm.cmd
class Config:
# VITE_NPM_BIN_PATH = environ.get("VITE_NPM_BIN_PATH") # This DID NOT WORK.
VITE_FOLDER_PATH = environ.get("VITE_FOLDER_PATH")
VITE_NPM_BIN_PATH = "C:\\Users\\<user>\\AppData\\Roaming\\npm\\pnpm.cmd" # This worked!
Description
Trying to follow along the example workflow - specifically the step for installing dependencies
What I Did
>flask vite init
Vite source directory and starter content installed in 'vite'.
>flask vite install
Flask app.py file:
The text was updated successfully, but these errors were encountered: