admin管理员组文章数量:1183193
Can't install the node-sass package via npm sudo npm i
, i have been trying to resolve via sudo npm i -g node-sass --unsafe-perm=true --allow-root
but it doesn't effect. Chmod 777 either.
I think there are something with npm permissions but i do not know
Log:
gyp verb build dir attempting to create "build" dir: /home/michael/Desktop/react/node_modules/node-sass/build
gyp ERR! configure error
gyp ERR! stack Error: EACCES: permission denied, mkdir '/home/michael/Desktop/react/node_modules/node-sass/build'
gyp ERR! System Linux 4.15.0-47-generic
gyp ERR! command "/usr/bin/node" "/home/michael/Desktop/react/node_modules/node-gyp/bin/node-gyp.js" "rebuild" "--verbose" "--libsass_ext=" "--libsass_cflags=" "--libsass_ldflags=" "--libsass_library="
gyp ERR! cwd /home/michael/Desktop/react/node_modules/node-sass
gyp ERR! node -v v11.14.0
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok
Build failed with error code: 1
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] postinstall: `node scripts/build.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] postinstall script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /home/michael/.npm/_logs/2019-04-13T17_21_20_424Z-debug.log
Can't install the node-sass package via npm sudo npm i
, i have been trying to resolve via sudo npm i -g node-sass --unsafe-perm=true --allow-root
but it doesn't effect. Chmod 777 either.
I think there are something with npm permissions but i do not know
Log:
gyp verb build dir attempting to create "build" dir: /home/michael/Desktop/react/node_modules/node-sass/build
gyp ERR! configure error
gyp ERR! stack Error: EACCES: permission denied, mkdir '/home/michael/Desktop/react/node_modules/node-sass/build'
gyp ERR! System Linux 4.15.0-47-generic
gyp ERR! command "/usr/bin/node" "/home/michael/Desktop/react/node_modules/node-gyp/bin/node-gyp.js" "rebuild" "--verbose" "--libsass_ext=" "--libsass_cflags=" "--libsass_ldflags=" "--libsass_library="
gyp ERR! cwd /home/michael/Desktop/react/node_modules/node-sass
gyp ERR! node -v v11.14.0
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok
Build failed with error code: 1
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] postinstall: `node scripts/build.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] postinstall script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /home/michael/.npm/_logs/2019-04-13T17_21_20_424Z-debug.log
Share
Improve this question
edited Apr 13, 2019 at 17:29
Michael Daineka
asked Apr 13, 2019 at 17:22
Michael DainekaMichael Daineka
1431 gold badge2 silver badges9 bronze badges
4 Answers
Reset to default 26As a general recommendation, never run npm install with sudo as it will create local files owned by root instead of your user, i think you shoud try the following :
- First change the owner of the folder :
chown -R yourusername:yourusername /home/michael/Desktop/react/
, or if you don't want to type your username :chown -R $USER:$USER /home/michael/Desktop/react/
- then run :
npm install node-sass
, do not use sudo
NOTE : This is fine when you install local packages, but for global installations, read the update below
UPDATE
Never Run sudo npm install
and sudo npm anything
read this article to get an idea why
While changing the permissions by using chown
or chmod
is kinda fine and works, however it isn't the best approach when installing packages globally, if you are on a Linux or OSX i would suggest you read this article on the npm docs here, and either use nvm
, or manually change npm's default directory.
Changing npm's default directory
To do so, you need to follow these steps :
On the command line, in your home directory, create a directory for global installations:
mkdir ~/.npm-global
Configure npm to use the new directory path:
npm config set prefix '~/.npm-global'
In your preferred text editor, open or create a
~/.profile
file [alternatively you can edit either the~/.bashrc
or~/.zshrc
file instead of.profile
if you see fit] and add this line :export PATH=~/.npm-global/bin:$PATH
On the command line, update your system variables:
source ~/.profile # or source ~/.bashrc, # source ~/.zshrc, depends on where you exported the path
To test your new configuration, install a package globally without using sudo:
npm install -g jshint
You can install node-sass globally :
npm install -g node-sass
Now you shoudn't get permissions errors as this should resolve the EACCES permissions errors when installing packages globally .
Warning
LibSass
and node-sass
are deprecated. While they will continue to receive maintenance releases indefinitely, there are no plans to add additional features or compatibility with any new CSS or Sass features, projects that still use it should move onto Dart Sass.
You can read more on this topic here
Please use sass instead, migrating to Dart Sass is straightforward And both packages expose the same JavaScript API, to install dart sass :
npm install sass
Or globally :
npm install -g sass
I followed the instructions as per @WaLid LamRaoui's answer as I also use to run npm install with sudo. It seemed to have done the trick in terms of changing the owner of the folder, but I still got an error when trying to run npm install
. I then realized another problem which has to do with my cache folder which contains root-owned files, so for those whose also have this problem after following the approved answer, I simply did this:
sudo chown -R 1003:1003 "/home/<username>/.npm"
After this I ran npm install
and it worked fine.
Do nothing ..
simply add --unsafe-perm
to it
Give it unsafe permission access.
So, let's say.. if you were previously installing bcrypt library
sudo npm install --save bcrypt
then now write
sudo npm install --unsafe-perm --save bcrypt
And you are done.
I solved this issue by running
sudo npm install -g --unsafe-perm node-sass
本文标签:
版权声明:本文标题:javascript - Npm error "Error: EACCES: permission denied, mkdir '..node-sassbuild'" - Stack Ov 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1738242260a2070974.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论