【问题标题】:Stop EACCES errors with npm/node on Ubuntu?在 Ubuntu 上使用 npm/node 停止 EACCES 错误?
【发布时间】:2014-08-12 07:38:12
【问题描述】:

设置系统环境

$ lsb_release -a 2> /dev/null | grep Desc
Description:    Ubuntu 14.04.1 LTS

$ sudo apt-get install build-essential
$ sudo add-apt-repository ppa:chris-lea/node.js && sudo apt-get update
$ sudo apt-get install nodejs && sudo npm update -g npm
$ sudo npm install -g yo generator-angular && cd /tmp && mkdir b && cd $_

生成(约曼)

/tmp/b $ yo angular
[?] Would you like to use Sass (with Compass)? No
[?] Would you like to include Bootstrap? No
[?] Which modules would you like to include? 
 ⬢ angular-animate.js
 ⬢ angular-cookies.js
 ⬡ angular-resource.js
 ⬡ angular-route.js
 ⬢ angular-sanitize.js
 ⬢ angular-touch.js

错误

npm-debug.log


是否有一些技巧(除了chowning /usr/lib/node_modules)可以阻止这些错误的发生?

【问题讨论】:

  • 快速,虽然不是最佳方式:手动,以 root 身份删除 /home/username/.npm

标签: node.js ubuntu npm sudo node-modules


【解决方案1】:

解决方案

(随意使用$HOME/npm以外的路径)

  1. 从全局 node_modules 文件夹 (/usr/lib/node_modules) 中删除除 npm 之外的所有内容
  2. $ mkdir "$HOME/npm"
  3. $ npm config set prefix "$HOME/npm"
  4. $ printf "NODE_PATH=$NODE_PATH:$HOME/npm/lib/node_modules\nPATH=$PATH:$HOME/npm:$HOME/npm/bin\n" >> ~/.bashrc && source ~/.bashrc

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-12-15
    • 2016-08-17
    • 2014-07-12
    • 2018-03-08
    • 2012-01-27
    • 2021-10-03
    • 1970-01-01
    相关资源
    最近更新 更多