简体   繁体   中英

Attempt to install node.js on OS X fails but I can't find support

Sorry if this is more detailed than anyone needs but I don't know stackoverflow well so I'm erring on the side of more info is better.

I'm really interested in exploring Amber, so I began to follow the online instructions in an article by Richard Eng [here][1]. Step 1 is to install node.js, so I went to the link in his piece at https://nodesource.com/blog/nodejs-v012-iojs-and-the-nodesource-linux-repositories but I was unable to find any information I could understand and use on that site so I searched for "install node.js os x" and ended up at this [page][2].

Following the instructions on that page (already had XCode installed), I downloaded and installed Homebrew, then followed the instructions in the Terminal. Things seemed to run fine but when I did the suggested npm -v command in the console, I got a not found error.

I searched for help installing with Homebrew and got to this [page][3]. It indicated there were in fact some issues and provided a way around it. So I selected those lines and pasted them into the terminal. The final line of that instruction list -- curl -L https://www.npmjs.com/install.sh | sh -- whirred and clicked for a while and then displayed in the terminal:

sh: rimraf: command not found
/Users/dan/.npm-packages/bin/npm -> /Users/dan/.npm-packages/lib/node_modules/npm/bin/npm-cli.js
npm ERR! Darwin 15.5.0
npm ERR! argv "/usr/local/bin/node" "/private/var/folders/q5/qng_fj592vscw92h8mv01j480000gn/T/npm.52096/package/cli.js" "install" "-gf"
npm ERR! node v6.2.0
npm ERR! npm  v4.3.0
npm ERR! path ../../../../../../private/var/folders/q5/qng_fj592vscw92h8mv01j480000gn/T/npm.52096/package/man/man7/npm-developers.7
npm ERR! code ENOENT
npm ERR! errno -2
npm ERR! syscall symlink

npm ERR! enoent ENOENT: no such file or directory, symlink '../../../../../../private/var/folders/q5/qng_fj592vscw92h8mv01j480000gn/T/npm.52096/package/man/man7/npm-developers.7' -> '/Users/dan/.npm-packages/share/man/man7/npm-developers.7'
npm ERR! enoent ENOENT: no such file or directory, symlink '../../../../../../private/var/folders/q5/qng_fj592vscw92h8mv01j480000gn/T/npm.52096/package/man/man7/npm-developers.7' -> '/Users/dan/.npm-packages/share/man/man7/npm-developers.7'
npm ERR! enoent This is most likely not a problem with npm itself
npm ERR! enoent and is related to npm not being able to find a file.
npm ERR! enoent 

npm ERR! Please include the following file with any support request:
npm ERR!     /Users/dan/.npm/_logs/2017-03-06T20_57_44_069Z-debug.log
It failed
(23) Failed writing body

I grabbed that log file but I'm darned if I can figure out where to send it or make a support request.

Can anyone help? I'm bound and determined to get Amber working regardless of what it takes.

Thanks for helping out an old-timer!

Dan

Here is a simple fix for those who installed node via Homebrew without npm and later on struggled with npm installation using an official script. This approach assumes you have run the node installation as follows:

brew install node --without-npm
echo prefix=~/.npm-packages >> ~/.npmrc
curl -L https://www.npmjs.com/install.sh | sh

If above failed then start from here. Remove npm if any:

rm -rf ~/.npm-packages/lib/node_modules/npm

Download and unpack the latest version of npm :

cd ~
curl -L https://registry.npmjs.org/npm/-/npm-5.6.0.tgz | tar xz

Move unpacked package into node_modules folder:

mv ~/package ~/.npm-packages/lib/node_modules/npm

Add following to your ~/.bash_profile :

export NPM_PACKAGES="$HOME/.npm-packages"
export NODE_PATH="$NPM_PACKAGES/lib/node_modules:$NODE_PATH"
export PATH="$NPM_PACKAGES/bin:$PATH"

Source the file:

source ~/.bash_profile

Verify installation:

npm -v

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM