Two days ago looked at Coffeescript, based on node. JS, incidentally Configure a node environment bar, toss for a long time
1. Download the MSI installation Environment from node. js
After the installation is complete open the installation directory, you can see a node.exe open can be executed in the JS code, similar to the chrome console, attention is not executed here node command! All of the following execution environments are cmd.
Open cmd, input node-v will return the current node version, indicating successful installation
The latest installation package already comes with NPM, npm-v see if NPM is installed successfully
2. Installing Coffeescript
Enter NPM install coffee-script-g in cmd
If the error "error:enoent, stat ' C:\Users\Administrator\AppData\Roaming\npm '", please create a NPM file manually in the corresponding directory
This time, it will output a lot of paths, so the basic success
Restart cmd input coffee-v to see if the installation was successful
Now you can compile the JS file with Coffee-c xxx.js
I encountered a problem in this step, prompted coffee is not internal or external commands, repeated installation several times unsuccessful, several times after the installation has succeeded in re-enter and prompted no such command
Finally uninstalled the node. JS again and did not know whether it was my environmental problem or network problem
3. Using Coffeescript in node. js
First use require (' coffee-script/register ') containing coffee's compilation environment note not require (' coffee-script ')
Then create and reference a coffee file
Execute node index.js error "Cannot find module ' Coffee-script/register"
Need to add environment variable Node_path, specific variable address can be found using NPM list Coffee-script
My local values are probably as follows "C:\Users\Administrator\AppData\Roaming\npm\node_modules
Restart CMD to compile the file again successfully!
WINDOW7 configuring node. js and Coffeescript environments