无法在我的Macbook上安装咖啡脚本

时间:2013-06-02 00:24:17

标签: javascript coffeescript installation

我尝试通过以下命令安装coffee-script:

npm -g install coffee-script

然后我收到了这些错误,

npm http GET https://registry.npmjs.org/coffee-script
npm http 200 https://registry.npmjs.org/coffee-script
npm http GET https://registry.npmjs.org/coffee-script/-/coffee-script-1.6.2.tgz
npm http 200 https://registry.npmjs.org/coffee-script/-/coffee-script-1.6.2.tgz
npm ERR! Error: EACCES, mkdir '/usr/local/lib/node_modules/coffee-script'
npm ERR!  { [Error: EACCES, mkdir '/usr/local/lib/node_modules/coffee-script']
npm ERR!   errno: 3,
npm ERR!   code: 'EACCES',
npm ERR!   path: '/usr/local/lib/node_modules/coffee-script',
npm ERR!   fstream_type: 'Directory',
npm ERR!   fstream_path: '/usr/local/lib/node_modules/coffee-script',
npm ERR!   fstream_class: 'DirWriter',
npm ERR!   fstream_stack:
npm ERR!    [ '/usr/local/lib/node_modules/npm/node_modules/fstream/lib/dir-writer.js:36:23',
npm ERR!      '/usr/local/lib/node_modules/npm/node_modules/mkdirp/index.js:37:53',
npm ERR!      'Object.oncomplete (fs.js:107:15)' ] }
npm ERR!
npm ERR! Please try running this command again as root/Administrator.

npm ERR! System Darwin 12.3.0
npm ERR! command "node" "/usr/local/bin/npm" "-g" "install" "coffee-script"
npm ERR! cwd /Users/cinker
npm ERR! node -v v0.10.9
npm ERR! npm -v 1.2.24
npm ERR! path /usr/local/lib/node_modules/coffee-script
npm ERR! fstream_path /usr/local/lib/node_modules/coffee-script
npm ERR! fstream_type Directory
npm ERR! fstream_class DirWriter
npm ERR! code EACCES
npm ERR! errno 3
npm ERR! stack Error: EACCES, mkdir '/usr/local/lib/node_modules/coffee-script'
npm ERR! fstream_stack /usr/local/lib/node_modules/npm/node_modules/fstream/lib/dir-writer.js:36:23
npm ERR! fstream_stack /usr/local/lib/node_modules/npm/node_modules/mkdirp/index.js:37:53
npm ERR! fstream_stack Object.oncomplete (fs.js:107:15)
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR!     /Users/cinker/npm-debug.log
npm ERR! not ok code 0

然后我想在sudo模式下使用npm来覆盖之前的安装,但终端控制台再次用不同的语言警告。

npm http GET https://registry.npmjs.org/coffee-script
npm http 304 https://registry.npmjs.org/coffee-script
/usr/local/bin/coffee -> /usr/local/lib/node_modules/coffee-script/bin/coffee
/usr/local/bin/cake -> /usr/local/lib/node_modules/coffee-script/bin/cake
npm WARN package.json github-url-from-git@1.1.1 No repository field.
npm WARN package.json assert-plus@0.1.2 No repository field.
npm WARN package.json ctype@0.5.2 No repository field.

当我执行coffee-script时,它可以工作。但是,当我运行蛋糕时会出现错误。

所以我的问题是: 1.我在安装上做了什么错了? 2.我可以删除咖啡脚本并重新安装吗? 3.有没有其他方法可以做到这一点?(我试过自制软件,但失败了)?

非常感谢!

2 个答案:

答案 0 :(得分:1)

  • 作为suggested by Isaac,您也可以这样做,然后将咖啡安装为全局模块:

sudo chown -R $USER /usr/local

  • 是的,您可以毫无伤害地删除咖啡脚本安装。
  • Npm是安装咖啡的好方法,尝试重新安装。

答案 1 :(得分:1)

我建议:

sudo npm -g install coffee-script

这将保持/ usr / local目录的安全性,同时为用户提供系统-execute-权限,而无需将/ usr / local的所有权更改为一个用户。