在 mac 10.7.2 上安装 coffeescript 时出错 [英] error installing coffeescript on mac 10.7.2

查看:17
本文介绍了在 mac 10.7.2 上安装 coffeescript 时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Node 和 npm 都已安装且处于最新状态,但在尝试安装 coffeescript 时不断出现此错误.我还是编程新手,所以任何建议都将不胜感激.

Node and npm are both installed and up to date but keep getting this error when trying to install coffeescript. I am still new to programming so any advice would be greatly appreciated.

test-macbook:~ Test$ npm -v
1.1.0-3
test-macbook:~ Test$ node -v
v0.6.8
test-macbook:~ Test$ npm install -g coffee-script
npm http GET https://registry.npmjs.org/coffee-script
npm http 304 https://registry.npmjs.org/coffee-script
npm ERR! Could not create /usr/local/lib/node_modules/___coffee-script.npm
npm ERR! error installing coffee-script@1.2.0

npm ERR! Error: EACCES, permission denied '/usr/local/lib/node_modules/___coffee-script.npm'
npm ERR! 
npm ERR! Please try running this command again as root/Administrator.
npm ERR! 
npm ERR! System Darwin 11.2.0
npm ERR! command "node" "/usr/local/bin/npm" "install" "-g" "coffee-script"
npm ERR! cwd /Users/Dylan
npm ERR! node -v v0.6.8
npm ERR! npm -v 1.1.0-3
npm ERR! path /usr/local/lib/node_modules/___coffee-script.npm
npm ERR! code EACCES
npm ERR! message EACCES, permission denied '/usr/local/lib/node_modules/___coffee-script.npm'
npm ERR! errno {}
npm ERR! 
npm ERR! Additional logging details can be found in:
npm ERR!     /Users/Dylan/npm-debug.log
npm not ok

推荐答案

错误信息比较清楚:

npm ERR! Error: EACCES, permission denied '/usr/local/lib/node_modules/___coffee-script.npm'
npm ERR! 
npm ERR! Please try running this command again as root/Administrator.

您无法将其安装在 /usr/local/lib/node_modules 中,因为您没有必要的权限.尝试使用 sudo:

You can't install it in /usr/local/lib/node_modules because you don't have the necessary permissions. Try using sudo:

dylan-hermans-macbook:~ sudo npm install -g coffee-script

<小时>

npm 作者建议不要使用 sudo,因为包可以运行任意命令,所以 sudo npm install 很危险.他建议将 /usr/local 的所有权切换给您的用户.我认为这是一个可怕的建议,只会给你一种虚假的安全感:如果一个包可以运行任意命令,那么它可能会弄乱你的主目录(包括你所有的个人数据、可执行文件、配置和启动文件,......)sudo 或谁拥有 /usr/local 所以不使用 sudo 真的对你没有多大帮助.如果您不信任某个软件包,请不要安装它;如果你不信任一个包,那么你怎么能使用它呢?/usr/local 树仍然是系统目录树,OSX 仍然是多用户操作系统.


The npm author recommends not using sudo because packages can run arbitrary commands so sudo npm install is dangerous. He suggests switching the ownership of /usr/local to your user. I think that's horribly advice that just gives you a false sense of security: if a package can run arbitrary commands then it can mess with your home directory (including all your personal data, executables, config and startup files, ...) regardless of sudo or who owns /usr/local so not using sudo really doesn't do much for you. If you don't trust a package then don't install it; if you don't trust a package then how can you even use it? The /usr/local tree is still a system directory tree and OSX is still a multi-user operating system.

IMO 更好的解决方案是双重的:

IMO a much better solution is twofold:

  1. 请勿安装或使用任何您不信任的软件包.如果您安装它,那么您就相信该代码就是您(除非您总是要在某种监狱中运行它,但是如果您要达到这些长度,最好自己编写代码).
  2. 不要管 sudo/usr/local 并将其全部安装在您的主目录中.您将面临与使用 sudo 或更改 /usr/local 所有权相同的大部分危险,但至少您不会养成坏习惯.
  1. Don't install or use any packages that you don't trust. If you install it then you're trusting that code to be you (unless you're always going to run it in a jail of some sort but if you're going to those lengths you're probably better off writing the code yourself).
  2. Leave sudo and /usr/local alone and install it all inside your home directory. You'll be subject to most of the same dangers as using sudo or changing the /usr/local ownership but at least you won't be picking up bad habits.

这篇关于在 mac 10.7.2 上安装 coffeescript 时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆