NPM modules won't install globally without sud

2019-01-01 17:10发布

I have just reinstalled Ubuntu 12.04 LTS, and before anything else i did these steps:

  1. Installed Node via package manager with the following script

    sudo apt-get update
    
    sudo apt-get install python-software-properties python g++ make
    
    sudo add-apt-repository ppa:chris-lea/node.js
    
    sudo apt-get update
    
    sudo apt-get install nodejs
    
  2. Tried to install yeoman, express, n, yeoman's generators globally and all of them returned the same error

    npm ERR! Error: EACCES, symlink '../lib/node_modules/n/bin/n'

    npm ERR! { [Error: EACCES, symlink '../lib/node_modules/n/bin/n'] errno: 3, code: 'EACCES', path: '../lib/node_modules/n/bin/n' }

    npm ERR!

    npm ERR! Please try running this command again as root/Administrator.

    npm ERR! System Linux 3.8.0-29-generic

    npm ERR! command "/usr/bin/node" "/usr/bin/npm" "install" "-g" "-d" "n"

    npm ERR! cwd /home/heberlz

    npm ERR! node -v v0.10.20

    npm ERR! npm -v 1.3.11

    npm ERR! path ../lib/node_modules/n/bin/n

    npm ERR! code EACCES

    npm ERR! errno 3

    npm ERR! stack Error: EACCES, symlink '../lib/node_modules/n/bin/n'

    npm ERR!

    npm ERR! Additional logging details can be found in:

    npm ERR! /home/heberlz/npm-debug.log

    npm ERR! not ok code 0

  3. Reclaimed ownership of the following folders recursively ~/.npm, /usr/lib/node, /usr/lib/node_modules, and of the following symlinks /usr/bin/node, /usr/bin/nodejs with absolutely no success

I need to install yeoman and its generators without sudo not to be in trouble later on :(

13条回答
只靠听说
2楼-- · 2019-01-01 17:41

using lubuntu 14.04.3, I tried changing ownership of .npm and npm prefix, updated my path, npm installed modules to my home directory without sudo but the path was incorrect so the modules like ember were not found, linuxbew solved the problem, quick setup guide here for node/npm

查看更多
登录 后发表回答