Windows, VSC, Running npm start
got this
npm WARN lifecycle The node binary used for scripts is C:\Program Files\nodejs\node.exe but npm is using C:\somewhere\AppData\Roaming\npm\node_modules\node\bin\node.exe itself. Use the
--scripts-prepend-node-path
option to include the path for the node binary npm was executed with.
I understand it means my local version is diff from the one in the PATH variable (C:\Program Files...). How do proceed to tell it to use --scripts-prepend-node-path
?
I played a trick by replacing the C:\Program Files\nodejs
with C:\somewhere\AppData\Roaming\npm\node_modules\node\bin
in PATH variable, it does pick up that new node.exe got but there is no node binary in the current PATH
. Again recommend to use the --scrip ts-prepend-node-path
option to include the path for the node binary npm was executed with
By default, the installer uses the Node. js distribution in C:\Program Files\nodejs. The installer should set the C:\Program Files\nodejs\bin directory in window's PATH environment variable.
Type in npm root -g to see what the current path your npm is installed to.
npmrc is the configuration file that npm allows to be used globally or user level or project level to optimize your npm environment.
The usual way to run a Node. js program is to run the globally available node command (once you install Node. js) and pass the name of the file you want to execute. While running the command, make sure you are in the same directory which contains the app.
Like I said, replacing the actual path in PATH system variable didn't fix the problem completely, it still complained about binary is missing. Found this solved the there is no node binary in the current PATH
problem. So I restored the original PATH, then:
Simply create a file at the root folder of the app, called .npmrc, place this line into it:
scripts-prepend-node-path=true
Here's another way that works: npm config set scripts-prepend-node-path auto
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With