Programing

npm install -g less가 작동하지 않습니다

lottogame 2020. 6. 10. 23:16
반응형

npm install -g less가 작동하지 않습니다


phpless를 덜 설정하여 저장시 .less 파일을 .css로 컴파일 할 수 있습니다. node.js를 설치했으며 다음 단계 (이 https://www.jetbrains.com/webstorm/help/transpiling-sass-less-and-scss-to-css.html 에 따라 )에서이 명령을 실행 중입니다. 단말기

npm install -g less

그러나이 작업을 수행하면 이러한 오류가 발생합니다

☁  ~  npm install -g less
npm WARN install Couldn't install optional dependency: EACCES: permission denied, mkdir '/Users/brentscholl/.npm/mkdirp/0.5.1'
npm WARN install Couldn't install optional dependency: EACCES: permission denied, mkdir '/Users/brentscholl/.npm/graceful-fs/3.0.8'
npm WARN install Couldn't install optional dependency: EACCES: permission denied, mkdir '/Users/brentscholl/.npm/extend/3.0.0'
npm WARN install Couldn't install optional dependency: EACCES: permission denied, mkdir '/Users/brentscholl/.npm/readable-stream/2.0.4'
npm WARN install Couldn't install optional dependency: EACCES: permission denied, mkdir '/Users/brentscholl/.npm/chalk/1.1.1'
npm WARN install Couldn't install optional dependency: EACCES: permission denied, mkdir '/Users/brentscholl/.npm/xtend/4.0.1'
npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules
/usr/local/lib
└─┬ less@2.5.3
  ├─┬ errno@0.1.4
  │ └── prr@0.0.0
  ├── image-size@0.3.5
  ├── mime@1.3.4
  ├─┬ promise@6.1.0
  │ └── asap@1.0.0
  └─┬ source-map@0.4.4
    └── amdefine@1.0.0

npm ERR! Darwin 15.0.0
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "install" "-g" "less"
npm ERR! node v5.0.0
npm ERR! npm  v3.3.6
npm ERR! path /usr/local/lib/node_modules
npm ERR! code EACCES
npm ERR! errno -13
npm ERR! syscall access

npm ERR! Error: EACCES: permission denied, access '/usr/local/lib/node_modules'
npm ERR!     at Error (native)
npm ERR!  { [Error: EACCES: permission denied, access '/usr/local/lib/node_modules']
npm ERR!   errno: -13,
npm ERR!   code: 'EACCES',
npm ERR!   syscall: 'access',
npm ERR!   path: '/usr/local/lib/node_modules' }
npm ERR!
npm ERR! Please try running this command again as root/Administrator.

npm ERR! Please include the following file with any support request:
npm ERR!     /Users/brentscholl/npm-debug.log

나는 여기에 완전한 멍청한 놈이며 다음에 무엇을 해야할지 모르겠습니다. 어떤 도움이라도 대단히 감사하겠습니다!


sudo를 사용하지 않는 것이 좋습니다. 나중에 권한 문제가 발생할 수 있습니다. 위의 방법으로 작동하지만 루트가 소유 한 폴더를 사용자가 쓸 수 있도록 변경하는 것을 좋아하지는 않지만 여러 사용자에게만 문제가 될 수 있습니다. 이를 해결하기 위해 'npm users'와 함께 그룹을 사용할 수 있지만 관리 부담이 더 큽니다. https://docs.npmjs.com/getting-started/fixing-npm-permissions 문서의 권한을 처리하는 옵션에 대해서는 여기를 참조하십시오.

옵션 2로 갈 것입니다.

권한 오류 가능성을 최소화하기 위해 다른 디렉토리를 사용하도록 npm을 구성 할 수 있습니다. 이 예에서는 홈 폴더의 숨겨진 디렉토리가됩니다.

글로벌 설치 디렉토리를 작성하십시오.

 mkdir ~/.npm-global

새 디렉토리 경로를 사용하도록 npm을 구성하십시오.

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

~ / .profile 파일을 열거 나 작성하고 다음 행을 추가하십시오.

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

Back on the command line, update your system variables:

 source ~/.profile

Test: Download a package globally without using sudo.

npm install -g jshint

If still show permission error run (mac os):

sudo chown -R $USER ~/.npm-global   

This works with the default ubuntu install of:

sudo apt-get install nodejs npm

I recommend nvm if you want more flexibility in managing versions: https://github.com/creationix/nvm

On MacOS use brew, it should work without sudo out of the box if you're on a recent npm version. Enjoy :)


Run these commands in a terminal window (note: DON'T replace the $USER part... thats a linux command to get your user!):

sudo chown -R $USER ~/.npm
sudo chown -R $USER /usr/lib/node_modules
sudo chown -R $USER /usr/local/lib/node_modules

Reinstall node and npm with Node Version Manger (as per written in npm documentation) to avoid permission errors:

In OSX:

curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.8/install.sh | bash

or follow this article:

http://dev.topheman.com/install-nvm-with-homebrew-to-use-multiple-versions-of-node-and-iojs-easily/

Windows users should install nvm-windows. For further help how to install nvm refer the nvm readme.

Then choose for example:

nvm install 8.0.0
nvm use 8.0

Now you can give another try:

npm install -g less

Mac OS X Answer

You don't have write access to the node_modules directory

npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules

Add your User to the directory with write access

  1. Open folder containing node_modules

    open /usr/local/lib/

  2. Do a cmd+I on the node_modules folder to open the permission dialog
  3. Add your user to have read and write access in the sharing and permissions section enter image description here

Use sudo -i to switch to $root, then execute npm install -g xxxx


For my mac environment

sudo chown -R $USER /usr/local/lib/node_modules

solve the issue


Hi I'm using Ubuntu 18 and I had too got this error message when installing Prisma, then I just add sudo on front

sudo npm i -g prisma

참고URL : https://stackoverflow.com/questions/33725639/npm-install-g-less-does-not-work

반응형