I installed jshint using sudo npm install -g jshint
, and it seems to have worked:
$which jshint
/usr/local/bin/jshint
Yet running jshint
or its full path equivalent doesn't seem to do anything. It doesn't give an error, either–it just does nothing:
$jshint
$jshint --help
$jshint --verbose
$jshint --debug
$jshint admin.js
$jshint admin.js --verbose
$/usr/local/bin/jshint admin.js
I also tried symlinking nodejs per this answer:
$sudo ln -s /usr/bin/nodejs /usr/bin/node
$jshint admin.js --verbose
$jshint admin.js
$jshint --help
$man jshint
No manual entry for jshint
See 'man 7 undocumented' for help when manual pages are not available.
What am I missing here?
Edit: here's the output from apt-cache policy nodejs npm
. I'm just using the standard Ubuntu 14.04 packages, so there's nothing very special about this:
└─>apt-cache policy nodejs npm
nodejs:
Installed: 0.10.25~dfsg2-2ubuntu1
Candidate: 0.10.25~dfsg2-2ubuntu1
Version table:
*** 0.10.25~dfsg2-2ubuntu1 0
500 http://us.archive.ubuntu.com/ubuntu/ trusty/universe amd64 Packages
100 /var/lib/dpkg/status
npm:
Installed: 1.3.10~dfsg-1
Candidate: 1.3.10~dfsg-1
Version table:
*** 1.3.10~dfsg-1 0
500 http://us.archive.ubuntu.com/ubuntu/ trusty/universe amd64 Packages
100 /var/lib/dpkg/status
Best Answer
The official repos are a mess...
Installing Node and npm through the official repositories has always given me trouble. I suspect that this could be due to tools depending on
node
, when the actual command on Ubuntu isnodejs
, which is why creating a symlink should work. It worked for me in my quick test in a virtual machine, but since it didn't work for you, let's try something else...So, install Node.JS a different way
I generally prefer to install Node on Ubuntu using NVM. This avoids the issue of the
node
command not being defined on Ubuntu, and it avoids the permissions mess that requires usingsudo
to install npm modules.Do the following to get back to a clean slate:
Remove any global modules you've installed with npm (instructions here):
Remove symlinked node folder:
Uninstall the copies of
nodejs
andnpm
that you installed through Ubuntu's repositories:Clean up any other cruft:
At this point,
which node
,which nodejs
,which npm
, andwhich jshint
should all return nothing.Reinstall Node, skipping the official repositories
Grab the latest copy of NVM (you may need to
sudo apt-get install curl
first):Tell your shell to use
nvm
Then install a node version
And tell nvm which version of Node you want to use
Now you should be able to run Node with the
node
command, you should be able to install modules globally withoutsudo
, and you should end up with a working copy of jshint.If you don't want to run
nvm use v0.12
every time you start a new terminal session, you can addnvm use v
to your~/.bashrc
. Thev
isn't special, it will just matchv*
and find the latest version. Alternatively you could hard-code a specific version.