Express: Command Not Found & Unmet Dependency

342 Views Asked by At

I've looked through many posts and haven't found this specific problem. At this point it's unclear what I have installed/unistalled, but I was hopping that this error message and what follows would shed some light. It's a lot, but I felt more info would be helpful. It's also possible I'm missunderstanding some fundamental concept of express.

Machine:~$ npm install express -g
npm ERR! Error: EACCES, unlink '/Users/Machine/.node/lib/node_modules/express/History.md'
npm ERR!  { [Error: EACCES, unlink '/Users/Machine/.node/lib/node_modules/express/History.md']
npm ERR!   errno: 3,
npm ERR!   code: 'EACCES',
npm ERR!   path: '/Users/Machine/.node/lib/node_modules/express/History.md' }
npm ERR! 
npm ERR! Please try running this command again as root/Administrator.

npm ERR! System Darwin 13.4.0
npm ERR! command "node" "/usr/local/bin/npm" "install" "express" "-g"
npm ERR! cwd /Users/Machine
npm ERR! node -v v0.10.33
npm ERR! npm -v 1.4.28
npm ERR! path /Users/Machine/.node/lib/node_modules/express/History.md
npm ERR! code EACCES
npm ERR! errno 3
npm ERR! stack Error: EACCES, unlink '/Users/Machine/.node/lib/node_modules/express/History.md'
npm ERR! error rolling back Error: EACCES, unlink '/Users/Machine/.node/lib/node_modules/express/History.md'
npm ERR! error rolling back  { [Error: EACCES, unlink '/Users/Machine/.node/lib/node_modules/express/History.md']
npm ERR! error rolling back   errno: 3,
npm ERR! error rolling back   code: 'EACCES',
npm ERR! error rolling back   path: '/Users/Machine/.node/lib/node_modules/express/History.md' }
npm ERR! not ok code 0
Machine:~$ sudo npm install express -g
Password:
[email protected] /Users/Machine/.node/lib/node_modules/express
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected] ([email protected])
├── [email protected] ([email protected])
├── [email protected] ([email protected])
├── [email protected] ([email protected], [email protected])
├── [email protected] ([email protected], [email protected], [email protected])
├── [email protected] ([email protected], [email protected])
└── [email protected] ([email protected])
Machine:~$ ls
Applications        Movies          bin
Desktop         Music           node_modules
Documents       PdaNetUninstall.sh  package.json
Downloads       Pictures        perl5
Google Drive        Public          routes
Library         app.js          views
Machine:~$ cd Doc*
Machine:Documents$ ls
BDB             Practical Computer Concepts
Molecular Biology
Machine:Documents$ mkdir testFolder
Machine:Documents$ ls
BDB             Practical Computer Concepts
Molecular Biology       testFolder
Machine:Documents$ cd test*
Machine:testFolder$ ls
Machine:testFolder$ express mytestapp
-bash: express: command not found
Machine:testFolder$ 

As you can see, I've tried several different methods of installing experss, from using -g, to the npm install express-generator etc. Nothing has worked.

Of additional interest, when I run look at all the npm packages I have I this:

Machine:TestApp$ npm list
[email protected] /Users/Machine
├── UNMET DEPENDENCY body-parser@~1.8.1
├── UNMET DEPENDENCY cookie-parser@~1.3.3
├── UNMET DEPENDENCY debug@~2.0.0
├─┬ [email protected]
│ ├─┬ [email protected]
│ │ ├─┬ [email protected]
│ │ │ └── [email protected]
│ │ └── [email protected]
│ ├── [email protected]
│ ├── [email protected]
│ ├─┬ [email protected]
│ │ └── [email protected]
│ ├── [email protected]
│ ├── [email protected]
│ ├─┬ [email protected]
│ │ └── [email protected]
│ ├── [email protected]
│ ├── [email protected]
│ ├── [email protected]
│ ├── [email protected]
│ ├── [email protected]
│ ├─┬ [email protected]
│ │ └── [email protected]
│ ├── [email protected]
│ ├── [email protected]
│ ├─┬ [email protected]
│ │ ├── [email protected]
│ │ └── [email protected]
│ ├── [email protected]
│ ├── [email protected]
│ ├─┬ [email protected]
│ │ ├── [email protected]
│ │ ├── [email protected]
│ │ ├── [email protected]
│ │ └─┬ [email protected]
│ │   └── [email protected]
│ ├── [email protected]
│ ├─┬ [email protected]
│ │ └─┬ [email protected]
│ │   └── [email protected]
│ ├── [email protected]
│ └── [email protected]
├── UNMET DEPENDENCY jade@~1.6.0
├── UNMET DEPENDENCY morgan@~1.3.0
└── UNMET DEPENDENCY serve-favicon@~2.1.3

npm ERR! missing: body-parser@~1.8.1, required by [email protected]
npm ERR! missing: cookie-parser@~1.3.3, required by [email protected]
npm ERR! missing: morgan@~1.3.0, required by [email protected]
npm ERR! missing: serve-favicon@~2.1.3, required by [email protected]
npm ERR! missing: debug@~2.0.0, required by [email protected]
npm ERR! missing: jade@~1.6.0, required by [email protected]
npm ERR! not ok code 0
Machine:TestApp$ express -h
-bash: express: command not found
Machine:TestApp$ npm cache clean
npm ERR! Error: EACCES, unlink '/Users/Machine/.npm/abbrev/1.0.5'
npm ERR!  { [Error: EACCES, unlink '/Users/Machine/.npm/abbrev/1.0.5']
npm ERR!   errno: 3,
npm ERR!   code: 'EACCES',
npm ERR!   path: '/Users/Machine/.npm/abbrev/1.0.5' }
npm ERR! 
npm ERR! Please try running this command again as root/Administrator.

npm ERR! System Darwin 13.4.0
npm ERR! command "node" "/usr/local/bin/npm" "cache" "clean"
npm ERR! cwd /Users/Machine/Documents/BDB/Final Project/TestApp
npm ERR! node -v v0.10.33
npm ERR! npm -v 1.4.28
npm ERR! path /Users/Machine/.npm/abbrev/1.0.5
npm ERR! code EACCES
npm ERR! errno 3
npm ERR! stack Error: EACCES, unlink '/Users/Machine/.npm/abbrev/1.0.5'
npm ERR! 
npm ERR! Additional logging details can be found in:
npm ERR!     /Users/Machine/Documents/BDB/Final Project/TestApp/npm-debug.log
npm ERR! not ok code 0
1

There are 1 best solutions below

0
On

These steps will clean out any cruft that might be causing the issue and let you start as fresh as possible. I use a variants on this approach when I'm running into the same mysterious "it should work" situations with npm as you are seeing...

  1. sudo npm rm express -g to get rid of the global install...we're going to start fresh
  2. sudo npm cache clean to ... clean the cache. it's the 'turn it off and on again' of node
  3. sudo npm install express -g to start new

Side note: It is good practice to move the npm global installation directory to a place that won't require sudo. You can find several articles on how to do this both here on StackOverflow as well as via search engines...