How to include the path for the node binary npm was executed with

后端 未结 4 956
天命终不由人
天命终不由人 2021-01-30 03:06

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

相关标签:
4条回答
  • 2021-01-30 03:22

    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. Restored the original PATH, tried it worked.

    Simply create a file at the root folder of the app, called .npmrc, place this line into it:

    scripts-prepend-node-path=true

    0 讨论(0)
  • 2021-01-30 03:30

    Here's another way that works: npm config set scripts-prepend-node-path auto

    0 讨论(0)
  • 2021-01-30 03:37

    Conflict between your node binary and your npm


    In case the error looks something like:

    npm is trying to use the same node as the one it use to run itself.

    resolve this conflict by adding the node directory to your PATH:

    npm config set scripts-prepend-node-path true
    

    From the npm documentation:

    npm run sets the NODE environment variable to the node executable with which npm is executed. Also, if the --scripts-prepend-node-path is passed, the directory within which node resides is added to the PATH

    0 讨论(0)
  • 2021-01-30 03:40

    Having this issue in Visual Studio 2017, I instead told VS to always use the NodeJS that I had installed from nodejs.org rather than the frozen-in-time one that ships with Visual Studio. (The one that shipped with VS2015 is so ancient it doesn't really work anymore.)

    In Visual Studio, go to TOOLS > OPTIONS > search for EXTERNAL WEB TOOLS > and ensure "C:\Program Files\nodejs" (or wherever nodejs.org installed it) is first in the list of paths, adding it if necessary.

    0 讨论(0)
提交回复
热议问题