提问者:小点点

Webstorm找不到npm


我最近更新到Webstorm 2020.3,我得到以下错误:无法解析“npm”package Manager,这在升级之前是不一样的。

我已验证系统上是否安装了npm

 9:12am /Users/paymahn/sagebackend notify.of.payments ⬆ ⬇ ✭ ✱ ◼
 ❯❯❯ which npm
/usr/local/bin/npm
 9:12am /Users/paymahn/sagebackend notify.of.payments ⬆ ⬇ ✭ ✱ ◼
 ❯❯❯ npm -v
7.0.10

我还尝试手动将webstorm指向/usr/local/bin/npm,但这似乎没有帮助,因为/usr/local/bin/npm是一个符号链接。我试着把webstorm指向符号链接的文件

但当通过IDE从以下包.json执行NPM run Test时,出现以下错误:

    "scripts": {
        "lint": "./node_modules/.bin/eslint --max-warnings=0 .",
        "serve": "firebase serve --only functions",
        "shell": "firebase experimental:functions:shell",
        "start": "npm run shell",
        "deploy": "firebase deploy --only functions",
        "logs": "firebase functions:log",
        "prettier": "npx prettier --write .",
        "test": "mocha --reporter spec"
    },
/usr/local/Cellar/node/15.2.1/bin/node /usr/local/lib/node_modules/npm/bin/npm-cli.js test --scripts-prepend-node-path=auto

> test
> mocha --reporter spec

env: node: No such file or directory
npm ERR! code 127
npm ERR! path /Users/paymahn/sagebackend/functions
npm ERR! command failed
npm ERR! command sh -c mocha --reporter spec

但是,我可以成功地从命令行运行测试:

 9:19am /Users/paymahn/sagebackend/functions  ✘ 1 notify.of.payments ⬆ ⬇ ✭ ✱ ◼
 ❮❮❮ npm run test

> test
> mocha --reporter spec



  0 passing (1ms)

如何从webstorm成功执行npm命令


共1个答案

匿名用户

奇怪的是,退出webstorm并从终端启动一次似乎就解决了这个问题。现在我可以使用Alfred或Spotlight启动webstorm,这个问题就不会再出现了。

https://intellij-support.jetbrains.com/hc/en-us/community/posts/115000749210-get-env-node-no-sucle-file-or-directory-error-when-run-babel-in-intellij?page=1#community_comment_115000620244