错误安装coffeescript在mac 10.7.2 [英] error installing coffeescript on mac 10.7.2
问题描述
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
不使用 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:
- 不要安装或使用任何不信任的包。如果你安装它,那么你相信这段代码是你(除非你总是在一个监狱里运行它,但如果你要去那些长度,你可能更好自己编写代码)
- 单独保留
sudo
和/ usr / local
在您的主目录。您将受到与使用sudo
或更改/ usr / local
所有权相同的危险,但在至少你不会收获坏习惯。
- 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).
- 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 usingsudo
or changing the/usr/local
ownership but at least you won't be picking up bad habits.
这篇关于错误安装coffeescript在mac 10.7.2的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!