coffeescript install

2019-06-16 06:13发布

I can't install CoffeeScript on my Macbook. The same commands works just fine on my iMac.

$ surganov:~ surganov$ sudo npm install coffee-script -g
npm http GET https://registry.npmjs.org/coffee-script
npm http 304 https://registry.npmjs.org/coffee-script
/usr/local/share/npm/bin/coffee -> /usr/local/share/npm/lib/node_modules/coffee-script/bin/coffee
/usr/local/share/npm/bin/cake -> /usr/local/share/npm/lib/node_modules/coffee-script/bin/cake
coffee-script@1.3.3 /usr/local/share/npm/lib/node_modules/coffee-script

$ surganov:~ surganov$ coffee
-bash: coffee: command not found

3条回答
爷、活的狠高调
2楼-- · 2019-06-16 06:40

If you want to access coffescript binary globally, you need to install it so:

npm install -g coffee-script

And then add the installation directory to your PATH. Good way to automate this is to use nvm.

查看更多
可以哭但决不认输i
3楼-- · 2019-06-16 06:55

I had the same problem. When install with '-g', npm install to /usr/local/share/npm so you can't use, eg 'coffee' command. You can check where npm install node_modules with:

npm prefix -g

If it's not /usr/local then you can use npm config edit to edit prefix. It'll create a .npmrc file in your root (if it's not there). Otherwise, open the file with text editor and change the prefix. More info here: npm config

查看更多
劳资没心,怎么记你
4楼-- · 2019-06-16 06:55
  • Locate your coffeescript bin directory (by typing locate coffee)
  • Edit your ~/.profile file and add: export PATH=/usr/local/lib/node_modules/coffee-script/bin::$PATH (or whereever your coffee-script/bin is located)
  • Save the profile file
  • type source ~./profile (only this time) to load the new path
  • now you have the coffee command
查看更多
登录 后发表回答