Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript Express Basics (2015) Getting Started with Express Install Express.js

Darryn Smith
Darryn Smith
32,043 Points

Another Install express.js error

Went to install express and received the message below. When I checked the package.json file, there was no dependency record for express (or any other dependency for that matter)

āžœ  treehouse-express-basics git:(master) āœ— npm install express --save
npm WARN locking Error: EACCES, open '/Users/darryn/.npm/_locks/express-74b75cced64177e9.lock'
npm WARN locking     at Error (native)
npm WARN locking  /Users/darryn/.npm/_locks/express-74b75cced64177e9.lock failed { [Error: EACCES, open '/Users/darryn/.npm/_locks/express-74b75cced64177e9.lock']
npm WARN locking   errno: -13,
npm WARN locking   code: 'EACCES',
npm WARN locking   path: '/Users/darryn/.npm/_locks/express-74b75cced64177e9.lock' }
npm ERR! Darwin 14.5.0
npm ERR! argv "node" "/usr/local/bin/npm" "install" "express" "--save"
npm ERR! node v0.12.7
npm ERR! npm  v2.11.3

npm ERR! Attempt to unlock /Users/darryn/Development/express_basics/treehouse-express-basics/node_modules/express, which hasn't been locked
npm ERR! 
npm ERR! If you need help, you may report this error at:
npm ERR!     <https://github.com/npm/npm/issues>

npm ERR! Please include the following file with any support request:
npm ERR!     /Users/darryn/Development/express_basics/treehouse-express-basics/npm-debug.log

4 Answers

akak
akak
29,445 Points

Try running 'npm cache clean' and if that won't help try 'sudo chown -R whoami ~/.npm'.

If neither helps you can always do 'sudo npm install express --save'. I know you're not doing global install but it's worth a try since it looks like permission issues.

Darryn Smith
Darryn Smith
32,043 Points

It looks like the 'cache clean' approach worked.

If you have an extra minute or two, could you tell me what might have been choking up the cache that would cause the problem? I know you probably can't be sure but I'm only looking for some kind of hypothetical that I might retain for better understanding of whatever the problem might have been.

Thank you for your time and your brilliance!

akak
akak
29,445 Points

Unfortunately I'm far from being an expert in npm, but I've faced similar problem. After some research I've learned that when you install a package with npm it caches dependencies in the local cache. When you install a package that requires an already installed dependency npm takes it from the local cache rather than downloading and building it again. How that works exactly - I don't know, but I assume that it's prone to errors like: you uninstall a dependency but the record of it didn't get removed from cache and another package you try to install thinks there is a cache data, tries to use it, but there isn't.

Bottom line is that cache can get corrupted while using NPM, and if there are strange errors, it's worthwhile to clean it, as it's somehow likely it generates that error :)

Darryn Smith
Darryn Smith
32,043 Points

Well, I know more now than I did before. Thanks for taking the time.

Wanted to piggy back off your Express install error. I had similar trouble but instead of the locking errors displayed in your console I received "unable_to_verify_leaf_signature" and "unable to verify the first certificate" errors. After researching a little, these errors seem to deal with my requests being routed through a proxy server. Here is a helpful Stack Overflow post with the same issue on a different npm module.

My problem was the result of an outdated version of a monitoring service I use (Covenant Eyes) and after updating to the latest version (at the time of my post, Windows v 7.2.0). I had no trouble with the Express installation. Anyway, just wanted to suggest that people also check for a proxy if they are having trouble and hope this can help someone else :)