I'm trying to install a package called expo-cli
, but it is failing because npm keeps using the wrong version of node.
I'm setting my node version to v12.4.0, which I confirm is set. But when I run npm install -g expo-cli
, it keeps using v9.10.0
➜ ~ nvm current
v12.4.0
➜ ~ node -v
v12.4.0
➜ ~ npm install -g expo-cli
npm WARN deprecated [email protected]: This version has been deprecated in accordance with the hapi support policy (hapi.im/support). Please upgrade to the latest version to get the best features, bug fixes, and security patches. If you are unable to upgrade at this time, paid support is available for older versions (hapi.im/commercial).
npm WARN deprecated [email protected]: This module has moved and is now available at @hapi/hoek. Please update your dependencies as this version is no longer maintained an may contain bugs and security issues.
npm WARN deprecated [email protected]: This module has moved and is now available at @hapi/topo. Please update your dependencies as this version is no longer maintained an may contain bugs and security issues.
> @expo/[email protected] preinstall /Users/edmundmai/.nvm/versions/node/v9.10.0/lib/node_modules/expo-cli/node_modules/@expo/traveling-fastlane-darwin
> node platform.js
/Users/edmundmai/.nvm/versions/node/v9.10.0/bin/expo-cli -> /Users/edmundmai/.nvm/versions/node/v9.10.0/lib/node_modules/expo-cli/bin/expo.js
/Users/edmundmai/.nvm/versions/node/v9.10.0/bin/expo -> /Users/edmundmai/.nvm/versions/node/v9.10.0/lib/node_modules/expo-cli/bin/expo.js
> [email protected] install /Users/edmundmai/.nvm/versions/node/v9.10.0/lib/node_modules/expo-cli/node_modules/fsevents
> node install
How do I change npm to use node v12.4.0?
Expo-cli fails without the right version of node.
➜ ~ expo init my-app
zsh: command not found: expo
➜ ~ nvm list
v8.0.0
v9.10.0
v10.8.0
-> v12.4.0
default -> v12.4.0
node -> stable (-> v12.4.0) (default)
stable -> 12.4 (-> v12.4.0) (default)
iojs -> N/A (default)
lts/* -> lts/dubnium (-> N/A)
lts/argon -> v4.9.1 (-> N/A)
lts/boron -> v6.17.1 (-> N/A)
lts/carbon -> v8.16.0 (-> N/A)
lts/dubnium -> v10.16.0 (-> N/A)
➜ ~ nvm use v9.10.0
Now using node v9.10.0 (npm v6.9.0)
➜ ~ expo init my-app
/Users/edmundmai/.nvm/versions/node/v9.10.0/lib/node_modules/expo-cli/bin/expo.js:12
throw new Error('expo-cli supports Node versions 8.x.x, 10.x.x and newer.');
^
Error: expo-cli supports Node versions 8.x.x, 10.x.x and newer.
at Object.<anonymous> (/Users/edmundmai/.nvm/versions/node/v9.10.0/lib/node_modules/expo-cli/bin/expo.js:12:9)
at Module._compile (module.js:649:30)
at Object.Module._extensions..js (module.js:660:10)
at Module.load (module.js:561:32)
at tryModuleLoad (module.js:501:12)
at Function.Module._load (module.js:493:3)
at Function.Module.runMain (module.js:690:10)
at startup (bootstrap_node.js:194:16)
at bootstrap_node.js:666:3
UPDATE:
This is what happens when I try to scope the node version:
➜ ~ nvm run 12.4.0 npm install --latest-npm
Running node v12.4.0 (npm v6.9.0)
internal/modules/cjs/loader.js:626
throw err;
^
Error: Cannot find module '/Users/edmundmai/npm'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:623:15)
at Function.Module._load (internal/modules/cjs/loader.js:527:27)
at Function.Module.runMain (internal/modules/cjs/loader.js:837:10)
at internal/main/run_main_module.js:17:11 {
code: 'MODULE_NOT_FOUND',
requireStack: []
}
➜ ~ nvm exec 12.4.0 npm install -g expo-cli
Running node v12.4.0 (npm v6.9.0)
npm WARN deprecated [email protected]: This version has been deprecated in accordance with the hapi support policy (hapi.im/support). Please upgrade to the latest version to get the best features, bug fixes, and security patches. If you are unable to upgrade at this time, paid support is available for older versions (hapi.im/commercial).
npm WARN deprecated [email protected]: This module has moved and is now available at @hapi/hoek. Please update your dependencies as this version is no longer maintained an may contain bugs and security issues.
npm WARN deprecated [email protected]: This module has moved and is now available at @hapi/topo. Please update your dependencies as this version is no longer maintained an may contain bugs and security issues.
> @expo/[email protected] preinstall /Users/edmundmai/.nvm/versions/node/v9.10.0/lib/node_modules/expo-cli/node_modules/@expo/traveling-fastlane-darwin
> node platform.js
/Users/edmundmai/.nvm/versions/node/v9.10.0/bin/expo -> /Users/edmundmai/.nvm/versions/node/v9.10.0/lib/node_modules/expo-cli/bin/expo.js
/Users/edmundmai/.nvm/versions/node/v9.10.0/bin/expo-cli -> /Users/edmundmai/.nvm/versions/node/v9.10.0/lib/node_modules/expo-cli/bin/expo.js
> [email protected] install /Users/edmundmai/.nvm/versions/node/v9.10.0/lib/node_modules/expo-cli/node_modules/fsevents
> node install
To install the LTS version of Node, run nvm install lts . To install a specific version of Node, you need to run nvm list available first so you can see the versions of Node that are available. To install that specific version, run nvm install node-version-number . For example, nvm install 14.20.
You can install two versions of Node. js using nvm, and install different version of npm on each Node. js environment. For example, nvm install 14.18.
nvm manages node. js and npm versions. It's designed to be installed per-user and invoked per-shell. nvm works on any POSIX-compliant shell (sh, dash, ksh, zsh, bash), in particular on these platforms: unix, macOS, and windows WSL.
Check ~/.npmrc for a prefix setting that points to the v9.10.0 module install path. That will cause npm to install global packages in the wrong place when using other versions of node.
See: https://docs.npmjs.com/using-npm/config#prefix
You can try this: $ nvm run 12.4.0 npm install -g expo-cli
or this: $ nvm exec 12.4.0 npm install -g expo-cli
For reference: https://github.com/nvm-sh/nvm#usage
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With