Error when upgrading Node.js via npm

2.3k views Asked by At

Following the instructions at http://davidwalsh.name/upgrade-nodejs, to upgrade Node.js on a RedHat Fedora 16 server, I get the error...

cp: cannot overwrite directory `/usr/local/bin/node' with non-directory

... and the version of node remains unchanged.

node --version
v0.10.12

# sudo npm cache clean -f
npm WARN using --force I sure hope you know what you are doing.
# sudo npm install -g n
npm http GET https://registry.npmjs.org/n
npm http 200 https://registry.npmjs.org/n
npm http GET https://registry.npmjs.org/n/-/n-2.0.2.tgz
npm http 200 https://registry.npmjs.org/n/-/n-2.0.2.tgz
/usr/bin/n -> /usr/lib/node_modules/n/bin/n
npm WARN package.json [email protected] No repository field.
npm WARN package.json [email protected] No repository field.
npm WARN package.json [email protected] No repository field.
npm WARN package.json [email protected] No repository field.
npm WARN package.json [email protected] No repository field.
npm WARN package.json [email protected] No repository field.
npm WARN package.json [email protected] No repository field.
npm WARN package.json [email protected] No repository field.
npm WARN package.json [email protected] 'repositories' (plural) Not supported.
npm WARN package.json Please pick one as the 'repository' field
[email protected] /usr/lib/node_modules/n
# sudo n stable

     install : node-v0.12.7
       mkdir : /usr/local/n/versions/node/0.12.7
       fetch : https://nodejs.org/dist/v0.12.7/node-v0.12.7-linux-x64.tar.gz
cp: cannot overwrite directory `/usr/local/bin/node' with non-directory
   installed : v0.10.12

This is just on a test server, so there is no danger of disrupting the existing node service. What would be a simple way to get node to upgrade to 0.12.7?


EDIT: My solution was to rename /usr/local/bin/node then run taaem's node-install.sh script. When Node.js 0.12.7 was successfully installed, I could delete the original (renamed) directory.

1

There are 1 answers

0
kds On

Run the following commands which will upgrade the node version.

sudo npm cache clean -f
sudo npm install -g n
sudo n stable

The n package represents a Node helper, and running the last command upgrades node to the latest stable version.

Once your install is complete, you can confirm you version with another command

sudo n 0.8.21