Cannot install express globally

14,443

Solution 1

You're trying to install something globally, but you have no access to the global directory you're installing into.

Bad but acceptable advice would be to run sudo npm install -g express instead.

Solution 2

Use this instead

sudo npm install -g express-generator
Share:
14,443
Spearfisher
Author by

Spearfisher

Updated on June 11, 2022

Comments

  • Spearfisher
    Spearfisher almost 2 years

    I am trying to install express globally but everytime I run the command line 'npm install -g express' I get the following error message:

    npm http GET https://registry.npmjs.org/express
    npm http 200 https://registry.npmjs.org/express
    npm ERR! Error: EACCES, mkdir '/usr/local/lib/node_modules/express'
    npm ERR!  { [Error: EACCES, mkdir '/usr/local/lib/node_modules/express']
    npm ERR!   errno: 3,
    npm ERR!   code: 'EACCES',
    npm ERR!   path: '/usr/local/lib/node_modules/express',
    npm ERR!   fstream_type: 'Directory',
    npm ERR!   fstream_path: '/usr/local/lib/node_modules/express',
    npm ERR!   fstream_class: 'DirWriter',
    npm ERR!   fstream_stack: 
    npm ERR!    [ '/usr/local/lib/node_modules/npm/node_modules/fstream/lib/dir-writer.js:36:23',
    npm ERR!      '/usr/local/lib/node_modules/npm/node_modules/mkdirp/index.js:37:53',
    npm ERR!      'Object.oncomplete (fs.js:107:15)' ] }
    npm ERR! 
    npm ERR! Please try running this command again as root/Administrator.
    
    npm ERR! System Darwin 13.0.0
    npm ERR! command "node" "/usr/local/bin/npm" "install" "-g" "express"
    npm ERR! cwd /Folder
    npm ERR! node -v v0.10.26
    npm ERR! npm -v 1.4.3
    npm ERR! path /usr/local/lib/node_modules/express
    npm ERR! fstream_path /usr/local/lib/node_modules/express
    npm ERR! fstream_type Directory
    npm ERR! fstream_class DirWriter
    npm ERR! code EACCES
    npm ERR! errno 3
    npm ERR! stack Error: EACCES, mkdir '/usr/local/lib/node_modules/express'
    npm ERR! fstream_stack /usr/local/lib/node_modules/npm/node_modules/fstream/lib/dir-writer.js:36:23
    npm ERR! fstream_stack /usr/local/lib/node_modules/npm/node_modules/mkdirp/index.js:37:53
    npm ERR! fstream_stack Object.oncomplete (fs.js:107:15)
    npm ERR! 
    npm ERR! Additional logging details can be found in:
    npm ERR!     /Users/Folder/npm-debug.log
    npm ERR! not ok code 0
    

    Does anyone have a clue what the problem is?

  • Spearfisher
    Spearfisher about 10 years
    Thanks, just to understand a bit further, why is it bad to use the sudo command?
  • Andreas Hultgren
    Andreas Hultgren about 10 years
    @ArnaudDrizard It's not bad to run it with sudo