yo: command not found (Mac 10.9.4); no previous solutions work - node.js

Yeoman and bower do not work at all. I installed node using the Mac node package downloaded from the nodejs site.
npm: 1.4.21 / node: v0.10.30
.bash_profile:
export PATH=$HOME/local/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin
export M2_HOME=/Users/cmorrow/apache-maven-3.1.1
export PATH=$PATH:$M2_HOME/bin
export JAVA_HOME=/Library/Java/Home
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function*
export PATH=/usr/local/bin:$PATH
export PATH=/Users/cmorrow/npm/lib/node_modules:$PATH
I installed yo with:
npm install -g yo
The post install reads:
yo#1.2.1 postinstall /Users/cmorrow/npm/lib/node_modules/yo
node ./scripts/doctor
[Yeoman Doctor] Everything looks alright!

If you install nodejs by HomeBrew he manually create a symbolic link in the folder
/usr/local/bin
if the manually installation don't generate that symbolic link you can doing manually with this command (with sudo):
ln -s /Users/cmorrow/npm/lib/node_modules/yo/cli.js /usr/local/bin/yo
chmod +x /usr/local/bin/yo

Not sure the exact fix, but I made a few changes and everything now works.
Things I did were:
Upgraded node js to v0.10.31
sudo npm cache clean -f
sudo npm install -g n
sudo n stable
Reinstalled yeoman
sudo npm install -g yo

Related

npm command not found error but node is installed

I installed node and npm with Homebrew a while ago, they both worked fine until today when I keep running into the npm command not found error.
When is run $ whereis node, I get nothing back
When I do $ which node, I see /usr/local/bin/node
When I do $ node -v, I see v4.4.7
When I do $ whereis npm, I get nothing back
When I do $ which npm, I get nothing back
When I do $ npm -v, I see -bash: npm: command not found
I have tried
$ brew update
$ brew uninstall npm
$ brew install npm
I have also made sure that my $NODE_PATH environment variable is set:
# In ~/.bash_profile file:
export NODE_PATH="/usr/local/lib/node_modules"
I also followed these instructions from https://himanen.info/solved-npm-command-not-found/
Nothing seems to work and I keep getting npm: command not found when I run any command in any folder with npm. Any ideas? Thanks
I had the same issue, I am using a MAC.
It was a permission issue in my case, here is what I already did:
$ brew update
$ brew uninstall npm
$ brew install npm
That didn't work for me, so I tried this:
$ sudo chmod -R 777 /usr/local/lib
$ brew postinstall node
and this linked installed node with npm, when I typed:
$ npm -v
5.3.0
Now all commands followed by NPM are working fine,
like npm install
Hope this will work for all!!
Figured out the issue. So the root of the problem was that I installed npm using Homebrew and there are some issues with what goes on under the hood with Homebrew and npm.
To fix this I did the following:
rm -rf /usr/local/lib/node_modules
brew uninstall node
brew install node --without-npm
echo prefix=~/.npm-packages >> ~/.npmrc
curl -L https://www.npmjs.com/install.sh | sh
Important!
Do this in .bash_profile
export PATH="$HOME/.npm-packages/bin:$PATH"
export PATH="$HOME/.node/bin:$PATH"
Now everything works like a charm
In mac via homebrew, when you are getting error like
Error: Permission denied # dir_s_mkdir - /usr/local/lib/node_modules/npm
or mostly getting several folder permission, don't give full permission like
$ sudo chmod -R 777 /usr/local/lib
Please use as mentioned below
$ sudo chown -R $(whoami):admin /usr/local/lib/node_modules/
What it will do, simply gives the ownership to the user (linux users also can use this).
Hint: And in mac please use homebrew for installation. Advantages of homebrew you can switch between versions, easy to uninstall, you no need to run as root (sudo), like wise lots of advantages are there, as a developer its recommended to use homebrew (https://brew.sh/). And one more thing whenever you are getting some error like permission denied or something don't, give the full permission instead of using chmod use chown.
I had the same issue, I executed following command to install node and npm - it worked perfectly.
rm -rf /usr/local/lib/node_modules
brew uninstall node
brew install node

Error: EACCES when creating new Ember project

I just installed Linux Mint (version 17.2) and I'm trying to install Ember. Everything seemed to go fine, but I'm getting this error when I run ember new testProject.
create vendor/.gitkeep
EACCES, mkdir '/home/mkm/.npm/mkdirp/0.4.2'
Error: EACCES, mkdir '/home/mkm/.npm/mkdirp/0.4.2'
at Error (native)
Per a recommendation in the Ember Documentation I used this guide to install Node.js and NPM. Some of what I've read suggest the issue is nodejs was installed with sudo, but apt-get failed when I didn't use sudo.
I attempted to run the new project anyway. bower install completed successfully. But ember serve failed with Cannot find module 'chalk'.
--Version Info
$ ember --version
version: 1.13.8
Could not find watchman, falling back to NodeWatcher for file system events.
Visit http://www.ember-cli.com/user-guide/#watchman for more info.
node: 0.12.7
npm: 2.13.4
os: linux x64
The only command that was needed to run with sudo for me was:
npm install
I suggest you delete node_modules/ in your project directory completely, then run:
sudo npm install
You can also add option --verbose to see if everything is correctly installing and installation isn't stuck.
You could also change permissions for .npm directory to avoid some problems like that in future:
sudo chmod 777 -R /home/mkm/.npm
You can use following commands to install and use npm without sudo:
wget -qO- https://raw.githubusercontent.com/creationix/nvm/v0.25.4/install.sh | NVM_DIR="/home/your-user-name/.nvm" bash
export NVM_DIR="/home/your-user-name/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh"
nvm install 0.12
nvm alias default 0.12
npm install -g ember-cli
npm install -g bower
npm install -g phantomjs
Here is a link to nvm repository with latest version and documentation: https://github.com/creationix/nvm

npm upgrade with homebrew

When node (v.0.10.33) is installed with homebrew (v. 0.9.5), at one point it says:
==> Caveats
If you update npm itself do NOT use the npm upgrade command
Instead execute:
npm install -g npm#latest
So, what exactly is npm upgrade and what is the difference with npm install -g npm#latest?
-- edit 2015
the problem doesn't exist anymore with the current version of node. (but I never had an answer to what npm upgrade is?)
Use npm install to install a package and npm update to update a package.
That Homebrew npm caveat was removed after the issue with npm update -g was fixed.
npm comes bundled with node, both part of Node.js install --- no need to install separately
Below are the steps to install Node.js from source (OSX/linux)
Issue cmds as yourself NOT root (sudo)
to start fresh remove prior node and npm installs as well as these :
sudo mv ~/.npmrc ~/.npmrc_ignore
sudo mv ~/.npm ~/.npm_ignore
sudo mv ~/tmp ~/tmp_ignore
sudo mv ~/.npm-init.js ~/.npm-init.js_ignore
download source from : http://nodejs.org/download/
cd freshly-downloaded-dir
define environment variable NODE_PATH as the dir for subsequent module installs
export NODE_PARENT=${HOME}/nodejs-v0.10.33
export PATH=${NODE_PARENT}/bin:${PATH}
export NODE_PATH=${NODE_PARENT}/lib/node_modules
./configure --prefix=${NODE_PARENT}
make
make install # IMPORTANT this is NOT using sudo
# not wanted since installing into $USER owned $NODE_PARENT
which puts it into dir defined by above --prefix
when you use syntax : npm install -g some_cool_module
the -g for global installs it into dir $NODE_PATH and not your $PWD
Now put above three export xxx=yyy
commands into your ~/.bashrc or some such to persist these environment variable changes

Npm not working after Mavericks update

My npm in terminal isn't working after Mavericks update.
node app.js works well and runs my app, but when I run npm followed by anything I get -bash: npm: command not found. I know this question has been asked before here:
Global installation with npm doesn't work after Mac OS X Mavericks update
and
How do I install a module globally using npm?
and npm not working after reinstalling Mac OS X
, but none of the answers resolved my situation.
$ echo $PATH /usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/opt/X11/bin:/usr/local/mongodb/bin
How did you install node.js ? typically it comes bundled with both node and npm, where both are in the same directory. My suggestion is to remove your current install(s) and do the following with just works.
to install nodejs and npm as yourself NOT root do these commands (OSX/linux) :
parent_dir=${HOME}/bin_xxxx # replace bin_xxx with something specific
# to node release like bin_v0.10.31
mkdir ${parent_dir}
download source from : http://nodejs.org/download/
cd node-v0.xxxx
./configure --prefix=${parent_dir}/nodejs
make -j8
make install
which puts it into dir defined by above --prefix
export PATH=${parent_dir}/nodejs/bin:$PATH
define environment variable NODE_PATH so node can find dir for modules otherwise
npm install xxx will put newly installed module into dir in curr dir :
export NODE_PATH=${parent_dir}/nodejs/lib/node_modules
do above AND use syntax : npm install -g some_cool_module
always use the -g for global so it gets installed into dir $NODE_PATH
and not your $PWD
nodejs install gives you npm as well :
ls -la ${parent_dir}/nodejs/bin
For Debian, after installing node do following
curl -k -O -L https://npmjs.org/install.sh
ln -s /usr/bin/nodejs /usr/bin/node
sh install.sh

How do I know whether I have Node.js and npm successfully installed on Ubuntu 14.04?

I installed Node.js with these instructions and it seemed successful:
sudo add-apt-repository ppa:chris-lea/node.js
sudo apt-get update
sudo apt-get install nodejs
Then I installed npm with these instructions:
sudo curl https://www.npmjs.org/install.sh | sh
The nodejs installation seemed to work without errors but the npm command gave me a lot of errors. But it seems like they are installed because when I test what version I have they both come up:
nodejs -v
v0.10.30
npm -v
1.4.21
So If this doesn't tell me that I have both programs successfully installed, which I assume I do not, how do I know?
I think your tests tell that both or properly installed.
But you can try just type node in terminal & it should open a node shell, where you can check by running basic commands.
Current distributions of node.js (including the one you downloaded) already include npm. So maybe installing npm manually is one source of your errors. Beware that usually you run "npm install" with the permissions of a regular user. There are only some npm-based utilities that are to be installed with root permissions and the '-g' (global) command line switch.
On linux if you wish to install node.js and npm as yourself NOT root :
to start fresh remove prior node.js and npm installs as well as these :
~/.npmrc
~/.npm
~/tmp
~/.npm-init.js
create your ~/bin/ directory if not already created :
mkdir ${HOME}/bin
download source from : http://nodejs.org/download/
cd node-v0.10.30/
./configure --prefix=${HOME}/bin/nodejs
make -j8
make install
which puts it into dir defined by above --prefix
export PATH=${HOME}/bin/nodejs/bin:$PATH
define NODE_PATH so node can find dir for modules otherwise
npm install xxx will put newly installed module into dir in curr dir :
export NODE_PATH=${HOME}/bin/nodejs/lib/node_modules
do above AND use syntax :
npm install xxxxx -g
always use the -g for global which puts package xxxxx into $NODE_PATH
NOTE - nodejs install gives you npm as well :
ls -la ${HOME}/bin/nodejs/bin

Resources