How to fix "zsh: command not found: vue"? - macos

I installed #vue/cli on my mac, but whenever I type “vue”, my terminal says “zsh: command not found: vue” - How can I fix this problem? I searched similar issues and already spent half a day, but still not solved...
This is my environment:
macOS Catalina version 10.15
npm 6.4.1
node v10.13.0
I changed $PATH by doing this:
echo 'export PATH="/usr/local/bin:$PATH"' >> ~/.zshrc
Now this is:
echo $PATH
/usr/local/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/Apple/usr/bin:/Library/Apple/bin:/usr/local/share/dotnet:/opt/X11/bin:~/.dotnet/tools:/Library/Frameworks/Mono.framework/Versions/Current/Commands
It looks like #vue/cli is installed, but I don't know why vue command is not found. Don't I have an admin privilege?
~ % npm install -g #vue/cli
/Users/ami/.npm_global/bin/vue -> /Users/ami/.npm_global/lib/node_modules/#vue/cli/bin/vue.js
+ #vue/cli#4.0.5
updated 1 package in 46.758s
~ % node -v
v10.13.0
~ % npm -v
6.4.1
~ % vue -v
zsh: command not found: vue
~ % vue create new-project
zsh: command not found: vue
I'm following Vue CLI's instruction, so the result is supposed to be creating a new vue project.
https://cli.vuejs.org
SOLVED
Thank you for your advice!
I tried ~ % export PATH=~/.npm_global/bin:$PATH and my path became:
~ % echo $PATH
/Users/ami/.npm_global/bin
:/usr/local/bin
:~/.npm_global/bin
:/usr/local/bin
:~/.npm_global/bin
:/usr/local/bin
:/usr/bin
:/bin
:/usr/sbin
:/sbin
:/Library/Apple/usr/bin
:/Library/Apple/bin
:/usr/local/share/dotnet
:/opt/X11/bin:~/.dotnet/tools
:/Library/Frameworks/Mono.framework/Versions/Current/Commands
And try again:
~ % vue --version
#vue/cli 4.0.5
Worked!

the first you should remove all vue cli by enter 2 command
sudo npm uninstall --global vue-cli
sudo npm uninstall --global #vue/cli
then you should enter this commad for install the latest version of vue cli
sudo npm install --global #vue/cli#latest
I tried this in mac os 10.15.4 and worked
and then I install
#vue/cli 4.4.6
good luck :)

You have to change the .zhsrc in /Users/[username]/.zshrc and add:
export PATH=$PATH:/Users/[username]/.npm-global/bin
Check that your packages are in npm-global or npm-packages.
To see hidden file use cmd+shift+.

if none of the above work
npm config set prefix /usr/local
and
npm install -g #vue/cli
that's worked for me

I tried all of the above to no avail on Catalina 10.15.4
The fix is to
uninstall Node and Npm
go to Downloads Node.js and install the 64-bit version from Package
sudo npm install --global vue-cli
vue -V
2.9.6

mac os catalina with zsh terminal
Uninstalled node and npm using https://www.positronx.io/how-to-uninstall-node-js-and-npm-from-macos/
Downloaded node/npm from https://nodejs.org/en/download/current/
sudo npm install -g #vue/cli
vue --version (#vue/cli 4.5.4)

Open /etc/paths file with nano or some other editor as a superuser (sudo nano /etc/paths).
Add following line at the bottom
/usr/local/Cellar/node/15.2.1/bin
Before that, just check the node version (mine is 15.2.1).
Save changes, reboot your laptop and you're ready to go.

Related

how to update npm on macOS

For reasons unknown to me, I haven't been able to update to the latest version of npm on macOS (it works fine on Windows). It displays no error, only 'updated 1 package'.
Using Node.js 8.11.1
node -v
v8.11.1
What version of npm do I have?
$ npm -v
5.6.0
I tried this...
$ npm i -g npm
+ npm#5.8.0
updated 1 package in 7.37s
And it fails to update.
$ npm -v
5.6.0
Where is npm?
$ which npm
/usr/local/bin/npm
So I try brew...
brew install npm
And it fails...
$ npm -v
5.6.0
*And then I tried this... *
npm install npm#latest -g
+ npm#5.8.0
updated 1 package in 7.618s
And it fails...
npm -v
5.6.0
With sudo:
sudo npm i -g npm
+ npm#5.8.0
updated 1 package in 7.794s
And it fails...
npm -v
5.6.0
This also fails...
sudo npm install npm#latest -g
I followed the directions found on this Q&A, completely removing npm and node from my system and reinstalling them from scratch, and it also fails to update.
Screenshot, per request:
Close the terminal, and then re-open the terminal and running:
$ npm -v
5.6.0
sudo twice:
$ sudo npm i -g npm
+ npm#5.8.0
updated 1 package in 7.478s
$ sudo npm i -g npm
+ npm#5.8.0
updated 1 package in 7.434s
Also fails:
$ npm -v
5.6.0
What did I miss? What's going on here?
This works on my mac.
Based on docs https://docs.npmjs.com/troubleshooting/try-the-latest-stable-version-of-npm :
npm install -g npm#latest
There is a note stated on the docs that depends on your installation method, you might addd some sudo.
Upgrading on *nix (OSX, Linux, etc.)
(You may need to prefix these commands with sudo, especially on Linux,
or OS X if you installed Node using its default installer.)
npm install -g npm#latest
works fine!!
and you can also replace the latest for specific versions
like
npm install -g npm#5.6.0
I hope it will help!!!
Perhaps you have already solved this, but here is what I found when I had exactly this issue. I had 2 versions of npm installed.
I verified this as follows:
grep \"version\" ~/.npm-packages/lib/node_modules/npm/package.json
"version": "6.2.0"
grep \"version\" /usr/local/lib/node_modules/npm/package.json
"version": "5.6.0",
I worked around the issue by updating the path in my bash profile, but would like to know why (how) I ended up with 2 versions. Here is the update:
tail -2 ~/.bash_profile
NPM_PACKAGES="${HOME}/.npm-packages"
PATH="$NPM_PACKAGES/bin:$PATH"
In my case, none of the previous answers worked. For me, a working solution was a simple, five-step process.
Make sure (the old version of) npm is installed.
npm -v
If npm is not installed, then install it on the Mac with Node.js.
Globally installed the desired version of npm.
npm install -g npm#latest
This command uses the old version of npm (installed by Node), to globally install the latest version of npm at ~/.npm-global/. Once installed, close and open a new terminal shell.
Remove the old version of npm installed by Node
rm -r /usr/local/lib/node_modules/npm/
Sometimes this doesn't work, so I had to go into finder to delete the /npm/ folder.
Make sure to set the correct path variable.
echo $PATH
If ~/.npm-global/bin does not show up between the colons, then update the path variable. Open up ~/.zshrc in a text editor and add the following line. If you don't use zsh, open the profile for your corresponding shell (i.e. ~/.bash_profile)
export PATH=$PATH:$HOME/.npm-global/bin
Save your changes and close the text editor.
Close and reopen the terminal shell and run npm -v to check that npm is correctly on the latest version.
The reason for updating the path variable is because the npm cli suggests you update npm with npm install -g npm which will install npm at a different location than where Node installs npm originally.
In my case, only the following has helped:
sudo rm -rf /usr/local/lib/node_modules
sudo rm -rf ~/.npm
brew uninstall --ignore-dependencies node
brew install node
EDIT NOV 21: These days, I bypass brew entirely and use "n":
https://www.npmjs.com/package/n
And so I can change between versions too.
I faced the same problem.
You might have already installed the npm version, and now it is time to point the new npm version install. You can do that by following below steps.
sudo nano /usr/local/lib/node_modules/npm/package.json
change "version" : "5.6.0" to "verison": "5.8.0"
In my case, I'm using nvm to manage different versions of node. In order to upgrade npm version, I have to
1 - Install the latest version of npm by navigating to your current
version of node
cd ~/.nvm/versions/node/v10.9.0
npm install npm
or you can probably use
nvm install-latest-npm
2 - Edit $PATH to point to your current version of node
NPM_PACKAGES="${HOME}/.nvm/versions/node/v10.9.0"
PATH="$NPM_PACKAGES/bin:$PATH"
On my macOS the homebrew-installed npm did not want to upgrade due to pre-existing link file. I ran the install with --force flag and now things are okay.
$ npm --version
6.14.16
$ npm install -g npm#8
npm ERR! EEXIST: file already exists, symlink ...
$ npm install -g --force npm#8
npm WARN using --force I sure hope you know what you are doing.
+ npm#8.19.2
$ npm --version
8.19.2
Note also that in my case, no 'sudo' was required, thanks to homebrew. To check if your npm is installed with homebrew, use brew list.
$ brew list | grep node
node#12

Command error running installed npm modules

Hi guys could you help me? i've installed the latest version of node.js and installed cordova and ionic framework the problem starts is when i'm trying to run the ionic command, the console throw me the following message:
MacBook-Pro-de-Diego:~ diegochavez$ ionic start myApp
-bash: ionic: command not found
So then i looked for the root of my npm modules
MacBook-Pro-de-Diego:~ diegochavez$ npm root
/Users/diegochavez/node_modules
if you guys know something to fix this? Thanks in advance
First check if ionic is installed at path like /usr/local/lib/node_modules/ionic/bin/ionic. If it is there, you need to check the npm default global path.
Run command npm config get prefix to check the default path, it should be /usr/local. If it is not /usr/local, run command npm config set prefix /usr/local to set it. And then install again. Also see this answer
I having issue while running - sudo npm install -g gulp ionic with below version of node installed
node -v v0.10.15
npm -v 1.3.5
Error went way after I update node to latest version v0.10.26
The error you are getting is because ionic was not installed successfully. Trying updating node and run command as mentioned sudo npm install -g gulp ionic
Check where your npm folder is located. If your npm folder is located in $Home..then type this:
export PATH="$HOME/npm/bin:$PATH"
You need to run sudo npm install -g ionic from the command line.

PhoneGap Mac CLI local install failed because of Node version

So I want to debug my Phonegap webapp locally in Xcode.
I follow the step here and here, and launch in MAC CLI
$ sudo npm install -g phonegap
BUT install failed and CLI result get lots of errors with the first one is :
engine phonegap#2.9.0rc1-0.12.0: wanted: {"node":">=0.10.0"} (current: {"node":"v0.8.8","npm":"1.1.59"})
I understand my node version is too old : 0.8.8
node --version
I try to update but I am stuck with those 2 methods here and both in errors for me :
BREW
Tried Homebrew but did not work :
$ brew upgrade node
Error: node-0.8.8 already installed
NPM
As I found here
Upgrading Node.js to latest version
How do I update Node.js?
$ sudo npm install -g n
$ sudo n stable
sudo: n: command not found
In fact my bash_profile was missing the path to the n module as I found here:
cannot install npm? problems generating application
Edit your ~/.bash_profile. Add this export somewhere.
export PATH=/usr/local/bin:$PATH:/usr/local/share/npm/bin
I had the same issue and fixed it by upgrading node with brew, I just run
brew install --upgrade node

OSX Mountain Lion Cloud 9 install instructions

How can I install cloud9 locally on osx mountain lion?
following the instructions at https://github.com/ajaxorg/cloud9/ did not work.
You should check your nodejs version node --version. Use a version lower than 0.8.x
If you are already using 0.10.x and don't intend to go backwards, then you should try nvm:
curl https://raw.github.com/creationix/nvm/master/install.sh | sh
open a new terminal window (or do a shell logout + login)
nvm install 0.8
nvm use 0.8
Then follow cloud9 instructions
git clone https://github.com/ajaxorg/cloud9.git
cd cloud9
npm install
If this doesn't work try updating npm by executing npm update -g
NOTE: if you get EACCES errors then you should probably try sudo npm update -g
Ok, finally figured it out:
Using
node --version = v0.10.5
npm --version = 1.2.18
npm install cloud9
edit node_modules/cloud9/bin/cloud9.js
goto line 42
where: require("cloud9").main(options);
change to: require("../server/cloud9").main(options);
./node_modules/cloud9/bin/cloud9.sh
Haven't found any errors yet, but only just started using it.

Why does Grunt not add itself to the shell?

I have a problem installing grunt. All the documentation, and blog post tutorials, say that running:
npm install -g grunt
will then allow you to run grunt commands from the terminal.
I have a situation where grunt appears to install with no errors, but typing the command grunt in the terminal still gives:
-bash: grunt: command not found
What could I be doing wrong? And where could I find grunt to add it to my BASH profile manually?
Since Grunt version 0.4 (which was released 1 or 2 weeks ago) you need to install the grunt command line tool globally (if needed, use sudo before the command):
npm install -g grunt-cli
In your project location you then install the latest grunt version:
npm install grunt --save-dev
Option --save-dev will save the npm config in your package.json file, which makes it easier to install or reinstall the dependencies (using just npm install).
Try running the install with the verbose flag:
npm install -g grunt --verbose
You can see where it is being installed (something like /usr/local/share/npm/bin/grunt). Then check your path:
echo $PATH
If the path does not contain the install bin location, modify the path in your bash profile to include the location of the bin directory, then try grunt again in a fresh terminal.
UPDATE: Grunt 0.4 altered installation process. For 0.4 installs, see answer from asgoth below.
It seems that grunt in the current version 0.4.0 does not install a bin command. The last 0.3.x version is 0.3.17, which supports a bin command. To run grunt from the command line, you will want to install the grunt command line grunt-cli:
npm install -g grunt-cli --verbose
I had installed node using Homebrew and this was my solution:
set config for -g (GLOBAL) install directory directory: npm config
set prefix /Users/YOURNAME/.node/
make sure to edit PATH: sudo nano ~/.profile
add to path: export PATH=“/Users/YOURNAME/.node/bin:”$PATH
then update source: source ~/.profile
Following these steps will allow any packages installed using npm install -g somePKG to be placed in the correct location regardless of your current working directory. And by updating your $PATH correctly command line functions will work.
Information based on:
Fixing npm permissions - bit.ly/1CmIyqx

Resources