Reputation: 131
there are a few steps:
Use node v10+ instead of v14+.
(IMPT) add the following path to ~/.zshrc
(if you are using zsh)
/Users/[yourUsername]/.npm-packages/bin
/Users/[yourUsername]/.npm-global/bin
source ~/.zshrc
after modifying the file.Much thanks to @kissu and @Lakindu Hewawasam !!
-------original question-------
I'm on MacOS 10.15.5, node version v14.15.4, npm version 6.14.10.
I've been getting the error zsh: command not found: vue
, after trying multiple ways to download Vue.
I first tried npm install -g @vue/cli
, and it was giving me this error, so I uninstalled and tried again with sudo npm install -g @vue/cli @vue/cli-init --unsafe-perm
referring to this. Still, it doesn't work:
yingjieqiao@Yingjies-MacBook-Pro ~ % sudo npm install -g @vue/cli @vue/cli-init --unsafe-perm
npm WARN deprecated [email protected]: request has been deprecated, see https://github.com/request/request/issues/3142
npm WARN deprecated @hapi/[email protected]: Switch to 'npm install joi'
npm WARN deprecated @hapi/[email protected]: This version has been deprecated and is no longer supported or maintained
npm WARN deprecated @hapi/[email protected]: This version has been deprecated and is no longer supported or maintained
npm WARN deprecated @hapi/[email protected]: Moved to 'npm install @sideway/address'
npm WARN deprecated @hapi/[email protected]: This version has been deprecated and is no longer supported or maintained
npm WARN deprecated [email protected]: this library is no longer supported
npm WARN deprecated [email protected]: https://github.com/lydell/resolve-url#deprecated
npm WARN deprecated [email protected]: Please see https://github.com/lydell/urix#deprecated
npm WARN deprecated [email protected]: Chokidar 2 will break on node v14+. Upgrade to chokidar 3 with 15x less dependencies.
npm WARN deprecated [email protected]: fsevents 1 will break on node v14+ and could be using insecure binaries. Upgrade to fsevents 2.
npm WARN deprecated [email protected]: This package has been deprecated in favour of @vue/cli
npm WARN deprecated [email protected]: CoffeeScript on NPM has moved to "coffeescript" (no hyphen)
> [email protected] preinstall /Users/yingjieqiao/.npm-global/lib/node_modules/@vue/cli/node_modules/yarn
> :; (node ./preinstall.js > /dev/null 2>&1 || true)
/Users/yingjieqiao/.npm-global/bin/vue -> /Users/yingjieqiao/.npm-global/lib/node_modules/@vue/cli/bin/vue.js
> [email protected] install /Users/yingjieqiao/.npm-global/lib/node_modules/@vue/cli/node_modules/fsevents
> node install.js
SOLINK_MODULE(target) Release/.node
CXX(target) Release/obj.target/fse/fsevents.o
SOLINK_MODULE(target) Release/fse.node
> [email protected] postinstall /Users/yingjieqiao/.npm-global/lib/node_modules/@vue/cli/node_modules/core-js
> node -e "try{require('./postinstall')}catch(e){}"
Thank you for using core-js ( https://github.com/zloirock/core-js ) for polyfilling JavaScript standard library!
The project needs your help! Please consider supporting of core-js on Open Collective or Patreon:
> https://opencollective.com/core-js
> https://www.patreon.com/zloirock
Also, the author of core-js ( https://github.com/zloirock ) is looking for a good job -)
> @apollo/[email protected] postinstall /Users/yingjieqiao/.npm-global/lib/node_modules/@vue/cli/node_modules/@apollo/protobufjs
> node scripts/postinstall
> [email protected] postinstall /Users/yingjieqiao/.npm-global/lib/node_modules/@vue/cli/node_modules/nodemon
> node bin/postinstall || exit 0
> [email protected] postinstall /Users/yingjieqiao/.npm-global/lib/node_modules/@vue/cli/node_modules/ejs
> node ./postinstall.js
Thank you for installing EJS: built with the Jake JavaScript build tool (https://jakejs.com/)
npm WARN @vue/[email protected] requires a peer of [email protected] but none is installed. You must install peer dependencies yourself.
+ @vue/[email protected]
+ @vue/[email protected]
added 1367 packages from 714 contributors and updated 1 package in 43.692s
yingjieqiao@Yingjies-MacBook-Pro ~ % vue --version
zsh: command not found: vue
yingjieqiao@Yingjies-MacBook-Pro ~ % npm update -g @vue/cli
yingjieqiao@Yingjies-MacBook-Pro ~ % vue --version
zsh: command not found: vue
yingjieqiao@Yingjies-MacBook-Pro ~ %
In the warning message, it mentioned "xxx package will break on node v14+" a few times. But I think the download command in the official docs should work regardless?
Upvotes: 3
Views: 2029
Reputation: 46676
Looking for the comments just below the other answer, you may try adding those
export PATH="$PATH:$(yarn global bin)"
export PATH="$PATH:$HOME/.npm-global/bin"
to your ~/.zshrc
file since vue-cli is properly installed apparently.
Ofc, source ~/.zshrc
before trying to call the CLI again.
Upvotes: 2
Reputation: 46676
You should not install any package w/ a sudo
prefix.
How is your node version installed btw, via nvm
or manually ?
Maybe try to install it w/ yarn
.
Best idea would probably be to rollback and try to debug the issues on the recommended way. Maybe digging into specific issues on the github repo.
Btw, the post you're referencing is an old one so things probably changed in between.
I'm on Linux running the following versions (@vue/cli 4.5.9
is fine too, just upgraded).
EDIT: Also, this post may maybe help somehow.
Upvotes: 1
Reputation: 750
In my experience the node
version 10.23.0
works best for myself. So I recommend using this because I have solved errors like this using the version 10.23.0
.
Download here: https://nodejs.org/dist/latest-v10.x/
And then, once you have this version of node installed, run the command $ npm install vue
Upvotes: 2