Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Issues with installing node / running npm install

I am not very skilled in Linux so bear with me...

I am trying to install Node.js using these instructions:

sudo apt-get update
sudo add-apt-repository ppa:chris-lea/node.js
sudo apt-get update
sudo apt-get install nodejs=0.10.18-1chl1~precise1

that are found here: https://github.com/joyent/node/wiki/Installing-Node.js-via-package-manager

I ran these commands and after the last command I received this error:

Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help resolve the situation:

The following packages have unmet dependencies:
nodejs : Conflicts: npm
E: Unable to correct problems, you have held broken packages.

I next tried running the command sudo apt-get install nodejs which gave me no errors.

However, when I run "npm install" it fails presenting this:

npm ERR! install Couldn't read dependencies
npm ERR! Error: ENOENT, open '/home/sarah/package.json'
npm ERR! If you need help, you may report this log at:
npm ERR!     <http://github.com/isaacs/npm/issues>
npm ERR! or email it to:
npm ERR!     <[email protected]>

npm ERR! System Linux 3.8.0-30-generic
npm ERR! command "/usr/local/bin/node" "/usr/local/bin/npm" "install"
npm ERR! cwd /home/sarah
npm ERR! node -v v0.11.8-pre
npm ERR! npm -v 1.3.11
npm ERR! path /home/sarah/package.json
npm ERR! code ENOENT
npm ERR! errno -2
npm ERR! 
npm ERR! Additional logging details can be found in:
npm ERR!     /home/sarah/npm-debug.log
npm ERR! not ok code 0

Can anyone help me figure out what is going wrong? Thanks in advance

like image 696
Sarah Avatar asked Dec 15 '22 05:12

Sarah


1 Answers

This command: sudo apt-get install nodejs=0.10.18-1chl1~precise1 is just an ill-advised piece of documentation. Specifying the exact version number is a mistake in the common use case. So your use of just sudo apt-get install nodejs is the correct command and all should be well now.

After that it looks like you have both node and npm (they come together) successfully installed. Now you are trying to run npm install, which is normally run within a node module's directory and looks for a package.json file. Since your home directory is not a node module and doesn't contain a package.json file, you get an error.

Node is installed correctly and you are good to go. You can start developing a new module with npm init or you can clone an existing module from github for example, cd into that module's directory, and then run npm install and that should work.

like image 158
Peter Lyons Avatar answered Dec 17 '22 21:12

Peter Lyons