Install node using homegrown on OSX. Npm not found

Previously, I had a working installation of node and npm on OSX, but something went wrong when updating npm. Then I mixed things up with homebrew to try to bind, remove and reinstall node. Somewhere along the way, my initial installation of node, which used the installer from nodejs.com, and my use of brew in node. I finally got node reinstalled using homebrew, but when I try to run npm, I get the npm command not found. Here is the message I get when running brew install node.

$ brew install node ==> Downloading https://downloads.sf.net/project/machomebrew/Bottles/node-0.10.3 Already downloaded: /Library/Caches/Homebrew/node-0.10.32.mavericks.bottle.tar.gz ==> Pouring node-0.10.32.mavericks.bottle.tar.gz ==> Caveats Bash completion has been installed to: /usr/local/etc/bash_completion.d ==> make install npm ERR! npm ERR! Additional logging details can be found in: npm ERR! /usr/local/lib/node_modules/npm/npm-debug.log npm ERR! not ok code 0 make: *** [install] Error 3 Warning: The post-install step did not complete successfully You can try again using `brew postinstall node` ==> Summary 🍺 /usr/local/Cellar/node/0.10.32: 1678 files, 19M 

I tried to run postinstall node as indicated in the error message, but then get this error message.

 $ brew postinstall node ==> make install npm ERR! npm ERR! Additional logging details can be found in: npm ERR! /usr/local/lib/node_modules/npm/npm-debug.log npm ERR! not ok code 0 make: *** [install] Error 3 

Any ideas on installing my node installation?

Here is the last part of npm-debug.log

 30 silly resolved readmeFilename: 'README.md', 30 silly resolved _id: ' npm@1.4.24 ', 30 silly resolved _shasum: 'c0b916c7b6363d1fbde42c2d1420aca8e05a4118', 30 silly resolved _from: '.' } ] 31 info install npm@1.4.24 into /usr/local/lib 32 info installOne npm@1.4.24 33 verbose lib/node_modules/npm unbuild 34 info preuninstall npm@1.4.24 35 info uninstall npm@1.4.24 36 verbose true,/usr/local/lib/node_modules,/usr/local/lib/node_modules unbuild npm@1.4.24 37 verbose /usr/local/bin,[object Object] binRoot 38 verbose lib/node_modules/npm unbuild 39 info preuninstall npm@1.4.24 40 info uninstall npm@1.4.24 41 verbose true,/usr/local/lib/node_modules,/usr/local/lib/node_modules unbuild npm@1.4.24 42 verbose /usr/local/bin,[object Object] binRoot 43 error error rolling back Error: EACCES, unlink '/usr/local/share/man/man5/npm-folders.5' 43 error error rolling back npm@1.4.24 { [Error: EACCES, unlink '/usr/local/share/man/man5/npm-folders.5'] 43 error error rolling back errno: 3, 43 error error rolling back code: 'EACCES', 43 error error rolling back path: '/usr/local/share/man/man5/npm-folders.5' } 44 error Error: EACCES, unlink '/usr/local/share/man/man5/npm-folders.5' 44 error { [Error: EACCES, unlink '/usr/local/share/man/man5/npm-folders.5'] 44 error errno: 3, 44 error code: 'EACCES', 44 error path: '/usr/local/share/man/man5/npm-folders.5' } 45 error Please try running this command again as root/Administrator. 46 error System Darwin 13.4.0 47 error command "node" "/usr/local/lib/node_modules/npm/cli.js" "install" "-g" "-f" 48 error cwd /usr/local/lib/node_modules/npm 49 error node -v v0.10.32 50 error npm -v 1.4.24 51 error path /usr/local/share/man/man5/npm-folders.5 52 error code EACCES 53 error errno 3 54 error stack Error: EACCES, unlink '/usr/local/share/man/man5/npm-folders.5' 55 verbose exit [ 3, true ] 
+5
source share
5 answers

Do yourself a favor and use nvm . This will help you manage versions of Node, and you won’t need root privileges to use them.

Install nvm

Here we use curl to install a script for nvm and interpret this script using bash .

 curl https://raw.githubusercontent.com/creationix/nvm/v0.17.2/install.sh | bash 

Install node + npm

This command will find the latest stable version of node and install it on your system.

 nvm install stable 

( currently listening , use nvm install 0.10 now ...)

Tenacity

To have nvm configure your terminal each time a new window is opened, run the following command:

 nvm alias default stable 

( currently listening , use nvm alias default 0.10 at the moment ...)

Using

Now you can use Node as usual!

 node foo 

Read the nvm documentation!

Here: https://github.com/creationix/nvm

+7
source

Solving permission problems with Homebrew is often sudo chown -R $(whoami) $(brew --prefix) . If you have ever used npm as the root user, which should not be necessary, some of the files in its directory tree will be owned by root, which will lead to permission problems during the upgrade.

+3
source

I am on OSX and fixed this problem by downloading and installing the latest version from http://nodejs.org/ . This will give you the latest node and npm.

+1
source

I know this will not be an accepted answer, but you probably already did something like sudo npm -g install XXX and now have some resolution problems.

There are two places where this problem will take you:

 sudo chown -R `whoami`:staff /Users/`whoami` /usr/local 

The bottom line is that Node stores some things in / usr / local, and NPM stores some things in your HOME directory. If you touch any of them using sudo , you will have a bad time.

+1
source

If npm -v displays an error message after installing node, it indicates that a symlink is not created. If installation via brew occurs, a symbolic connection will be created. If installing some packages results in a warning, you should use the export command specified in the warning in the corresponding workspace folder

0
source

Source: https://habr.com/ru/post/1204461/


All Articles