Shawn's blog Shawn's blog
About Me
  • Category
  • Tag
  • Archive
GitHub (opens new window)

Shawn Jin

I am not a creator of knowledge, I am just a porter of knowledge.
About Me
  • Category
  • Tag
  • Archive
GitHub (opens new window)
  • Vuepress build got permission denied

Shawn Jin
2021-01-31
studyingnotes

Vuepress build got permission denied

# npm RACCES: permission denied

When I run npm run deploy to deploy my blog, the error "Error: EACCES: permission denied" shows up. However, it doesn't recommend to run as super user. To resolve it, there is two ways to do it.

# Option 1: Change the permission to npm's default directory.

Firstly, using npm config get prefix to get the npm directory. If it just /usr, switch to option 2.

Then using command sudo chown -R $(whoami) $(npm config get prefix)/{lib/node_modules,bin,share} to add premissions to user for only npm directories.

# Option 2: Change npm's default directory to another directory

  1. Make a directory for global installations:

    mkdir ~/.npm-global

  2. Configure npm to use the new directory path:

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

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

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

  4. Back on command line, update your system variables:

    source ~/.profile

To do a test, you could just download a package globally without using sudo

npm install node-g.raphael --save

# If you are using MacOS, then you could use brew install node to reinstall nodejs. Homebrew would set things up with correct permissions.

#Vuepress
Updated: 2021/09/09, 11:40:27
最近更新
01
Python import files from different directories
12-31
02
Classmethod in Python
09-15
03
Single/Double Star (/*) Parameters in Python
09-15
更多文章>
Theme by Vdoing | Copyright © 2019-2021 Shawn Jin | MIT License
  • 跟随系统
  • 浅色模式
  • 深色模式
  • 阅读模式