Error: EACCES: permission denied, access '/usr/lib/node_modules'

后端 未结 7 1976
甜味超标
甜味超标 2020-12-07 07:51

I am trying install typescript with command npm install -g typescript, and returns this error :

    npm ERR! Error: EACCES: permission denied, a         


        
7条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-07 08:08

    I have same issue with webpack server installation on globally, Use steps Solved my issue, my be work for you.

    Steps mention above There: Back-up your computer before you start.

    Make a directory for global installations:

    1. mkdir ~/.npm-global

    Configure npm to use the new directory path:

    2. npm config set prefix '~/.npm-global'

    Open or create a ~/.profile file and add this line:

    3. export PATH=~/.npm-global/bin:$PATH

    Back on the command line, update your system variables:

    4. source ~/.profile

    Test: Download a package globally without using sudo.

    npm install -g jshint

    Instead of steps 2-4, you can use the corresponding ENV variable (e.g. if you don't want to modify ~/.profile):

    NPM_CONFIG_PREFIX=~/.npm-global

提交回复
热议问题