【问题标题】:WebStorm cannot find npmWebStorm 找不到 npm
【发布时间】:2020-12-10 23:46:38
【问题描述】:

我最近更新到 WebStorm 2020.3,我收到以下错误:Cannot resolve '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从以下package.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 命令?

【问题讨论】:

标签: node.js npm webstorm


【解决方案1】:

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

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2014-11-15
    • 1970-01-01
    • 1970-01-01
    • 2012-03-18
    • 1970-01-01
    • 1970-01-01
    • 2015-09-03
    相关资源
    最近更新 更多