简体   繁体   中英

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. I checked with Terminal and it does satisfy the required version. my npm version

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).

What I had done includes the following:

  • Clear Cache, Remove package-lock.json, Remove node_modules, and reinstall - not working

  • rm all the node-related files and reinstall node (v14) - not working

  • use nvm to run - not working

Here is the debug log I got from 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).

This should also install npm at version 8.


To downgrade npm, you need to run the following command.

$ npm install -g npm@6.14.16

This should leave Node.js at the highest version, and npm at your desired version.

install n;

npm install -g n

or without node on 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...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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