Reputation: 104
I'm sorry if this is a duplicate: I've read several similar questions but haven't found a solution that explains this. Since I'm quite new to Linux (Elementary OS running on Ubuntu 12.04) I wanted to have a specific answer so I won't accidentally do something really stupid.
The last update on Node.js broke npm, and I don't know how to fix it. The easiest way for quick fixing seems to be just installing and reinstalling, so I learned how to do that. I'm using Chris Lea's ppa for Node.js.
Ran into some problems though. When running
$ which node
I get the folder reference /usr/bin/node, so I then ran $ cd /usr/bin/node
, and got the output:
bash: cd: /usr/bin/node: No such file or directory
. So I have a reference to a non-existing folder, and I have no idea to uninstall before reinstalling.
I'm able to run node file.js
but neither npm install package
or sudo npm install package
. When running with sudo (I know that this is stupid - but I had to try 'cus I was so frustrated) nothing gets installed on the system, it just lists the files from the package.
I pasted a bash script a while ago, which created and put my globals in my user folder, in a folder named .npm-packages
. I'm so new to Linux though, I have no idea how to fix this. The shebangs from the bin folder in .npm-packages
works globally.
So lost - if you can help me I'm more than thankful.
Thanks alot, Anton
Upvotes: 2
Views: 11421
Reputation: 104
This is what I did to get it working:
Step 1: Move ~/.npm to ~/.npm.bak
mv ~/.npm ~/.npm.bak
Step 2: Install a global npm package again, to recreate .npm I installed Yeoman - which will help me help you!
npm install -g yo
Step 3: Follow what Yeoman tells you and paste the echo command it gives you
[Yeoman Doctor] Uh oh, I found potential errors on your machine
// lots of text here
...
Or run this command
echo "export NODE_PATH=$NODE_PATH:/home/user/npm/lib/node_modules" >> ~/.bashrc && source ~/.bashrc
Upvotes: -2
Reputation: 54
You can't "Change Directory" into a file..
Inspect the path with ls -l /path/to/something
and you'll probably see its a file or symlink. If its a directory it will list the contents.
To list info on a directory try adding the d
flag.. EG: ls -ld /directory/path
Hang in there, this is the hardest part of the learning curve :-)
Upvotes: 0
Reputation: 943645
node
is an executable file, not a directory. You can't cd
to it.
You could cd
to /usr/bin/
which is the directory containing the node
executable file.
Upvotes: 6