简体   繁体   English

Mac NPM 版本错误

[英]Mac NPM Wrong Version

I am trying to get my project started but I got this error.我正在尝试启动我的项目,但出现此错误。 Error from Terminal来自终端的错误

The environment requires npm 6.x or lower.该环境需要 npm 6.x 或更低版本。 I checked with Terminal and it does satisfy the required version.我检查了终端,它确实满足所需的版本。 my npm version我的 npm 版本

I had once installed node v16 using the official installer before but soon I uninstalled it by following the steps I googled (like sudo rm all node-related stuff).我之前曾经使用官方安装程序安装过 node v16,但很快我按照我在谷歌上搜索的步骤卸载了它(比如 sudo rm all node-related stuff)。

What I had done includes the following:我所做的包括以下内容:

  • Clear Cache, Remove package-lock.json, Remove node_modules, and reinstall - not working清除缓存,删除 package-lock.json,删除 node_modules,然后重新安装 - 不工作

  • rm all the node-related files and reinstall node (v14) - not working rm 所有与节点相关的文件并重新安装节点(v14) - 不工作

  • use nvm to run - not working使用 nvm 运行 - 不工作

Here is the debug log I got from npm:这是我从 npm 获得的调试日志:

0 info it worked if it ends with ok
1 verbose cli [
1 verbose cli   '/Users/.nvm/versions/node/v12.22.12/bin/node',
1 verbose cli   '/Users/.nvm/versions/node/v12.22.12/bin/npm',
1 verbose cli   'run',
1 verbose cli   'start'
1 verbose cli ]
2 info using npm@6.14.16
3 info using node@v12.22.12
4 verbose run-script [ 'prestart', 'start', 'poststart' ]
5 info lifecycle sentry_fe@1.0.0~prestart: sentry_fe@1.0.0
6 info lifecycle sentry_fe@1.0.0~start: sentry_fe@1.0.0
7 verbose lifecycle sentry_fe@1.0.0~start: unsafe-perm in lifecycle true
8 verbose lifecycle sentry_fe@1.0.0~start: PATH: /Users/.nvm/versions/node/v12.22.12/lib/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin:/Users/Documents/WORK/governance-sentry-fe/node_modules/.bin:/Users/.nvm/versions/node/v12.22.12/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/puppetlabs/bin:/Applications/Visual Studio Code.app/Contents/Resources/app/bin:/Applications/Visual Studio Code.app/Contents/Resources/app/bin
9 verbose lifecycle sentry_fe@1.0.0~start: CWD: /Users/Documents/WORK/governance-sentry-fe
10 silly lifecycle sentry_fe@1.0.0~start: Args: [ '-c', 'eden start' ]
11 silly lifecycle sentry_fe@1.0.0~start: Returned: code: 1  signal: null
12 info lifecycle sentry_fe@1.0.0~start: Failed to exec start script
13 verbose stack Error: sentry_fe@1.0.0 start: `eden start`
13 verbose stack Exit status 1
13 verbose stack     at EventEmitter.<anonymous> (/Users/.nvm/versions/node/v12.22.12/lib/node_modules/npm/node_modules/npm-lifecycle/index.js:332:16)
13 verbose stack     at EventEmitter.emit (events.js:314:20)
13 verbose stack     at ChildProcess.<anonymous> (/Users/.nvm/versions/node/v12.22.12/lib/node_modules/npm/node_modules/npm-lifecycle/lib/spawn.js:55:14)
13 verbose stack     at ChildProcess.emit (events.js:314:20)
13 verbose stack     at maybeClose (internal/child_process.js:1022:16)
13 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:287:5)
14 verbose pkgid sentry_fe@1.0.0
15 verbose cwd /Users/Documents/WORK/governance-sentry-fe
16 verbose Darwin 21.3.0
17 verbose argv "/Users/.nvm/versions/node/v12.22.12/bin/node" "/Users/.nvm/versions/node/v12.22.12/bin/npm" "run" "start"
18 verbose node v12.22.12
19 verbose npm  v6.14.16
20 error code ELIFECYCLE
21 error errno 1
22 error sentry_fe@1.0.0 start: `eden start`
22 error Exit status 1
23 error Failed at the sentry_fe@1.0.0 start script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 1, true ]

Would any one imply other methods that I can use?有人会暗示我可以使用其他方法吗? Any responses would be appreciated.任何回应将不胜感激。

I'm not sure if I understand your question, but I'll try my best to answer.我不确定我是否理解你的问题,但我会尽力回答。

You can reinstall the latest version of Node.js from the official website (it should remove the old version).您可以从官方网站重新安装最新版本的 Node.js(它应该删除旧版本)。

This should also install npm at version 8.这也应该在版本 8 上安装 npm。


To downgrade npm, you need to run the following command.要降级 npm,您需要运行以下命令。

$ npm install -g npm@6.14.16

This should leave Node.js at the highest version, and npm at your desired version.这应该将 Node.js 保留为最高版本,并将 npm 保留为您想要的版本。

install n;安装 n;

npm install -g n

or without node on mac;或在 mac 上没有节点;

brew install n

after installation execute;安装后执行;

n 16.15.1

if you want other versions;如果你想要其他版本;

n <version>

or you can install last via;或者您可以通过最后安装;

n latest

i advise for new developers;我为新开发者提供建议;

n lts

also you can switch installed versions via您也可以通过以下方式切换已安装的版本

n

For more info...欲了解更多信息...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM