簡體   English   中英

Mac NPM 版本錯誤

[英]Mac NPM Wrong Version

我正在嘗試啟動我的項目,但出現此錯誤。 來自終端的錯誤

該環境需要 npm 6.x 或更低版本。 我檢查了終端,它確實滿足所需的版本。 我的 npm 版本

我之前曾經使用官方安裝程序安裝過 node v16,但很快我按照我在谷歌上搜索的步驟卸載了它(比如 sudo rm all node-related stuff)。

我所做的包括以下內容:

  • 清除緩存,刪除 package-lock.json,刪除 node_modules,然后重新安裝 - 不工作

  • rm 所有與節點相關的文件並重新安裝節點(v14) - 不工作

  • 使用 nvm 運行 - 不工作

這是我從 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 ]

有人會暗示我可以使用其他方法嗎? 任何回應將不勝感激。

我不確定我是否理解你的問題,但我會盡力回答。

您可以從官方網站重新安裝最新版本的 Node.js(它應該刪除舊版本)。

這也應該在版本 8 上安裝 npm。


要降級 npm,您需要運行以下命令。

$ npm install -g npm@6.14.16

這應該將 Node.js 保留為最高版本,並將 npm 保留為您想要的版本。

安裝 n;

npm install -g n

或在 mac 上沒有節點;

brew install n

安裝后執行;

n 16.15.1

如果你想要其他版本;

n <version>

或者您可以通過最后安裝;

n latest

我為新開發者提供建議;

n lts

您也可以通過以下方式切換已安裝的版本

n

欲了解更多信息...

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM