Node Mac 环境搭建

2018-03-02  本文已影响15人  9de75b652cd9

node 官网下载mac版本node按步骤安装

安装subline text3

1.为sublime text下载nodejs插件(下载地址:2.https://github.com/tanepiper/SublimeText-Nodejs)
3.解压下载的zip文件并将文件夹命名为Nodejs
4.复制Nodejs文件夹到sublime的Preferences-Package文件夹中
5.修改Nodejs.sublime-build和Nodejs.sublime-settings
6.修改后的Nodejs.sublime-settings

{  
  // save before running commands  
  "save_first": true,  
  // if present, use this command instead of plain "node"  
  // e.g. "/usr/bin/node" or "C:\bin\node.exe"  
  "node_command": "/usr/local/bin/node",  
  // Same for NPM command  
  "npm_command": "/usr/local/bin/npm",  
  // as 'NODE_PATH' environment variable for node runtime  
  "node_path": false,  
  
  "expert_mode": false,  
  
  "ouput_to_new_tab": false  
}  

7.修改后的Nodejs.sublime-build

{  
  "cmd": ["node", "$file"],  
  "file_regex": "^[ ]*File \"(...*?)\", line ([0-9]*)",  
  "selector": "source.js",  
  "shell":true,  
  "encoding": "cp1252",  
  "windows":  
    {  
        "cmd": ["taskkill /F /IM node.exe & node $file"]  
    },  
  "linux":  
    {  
        "cmd": ["killall node; node $file"]  
    },  
    "osx":  
    {  
        "cmd": ["/usr/local/bin/node; node $file"]  
    }  
}  

再重启sublime,选中Tool-build System-Nodejs
编辑Nodejs文件,并保存为后缀为js的文件(如果不保存为.js文件,sublime是无法显示运行结果的)这样我们就可以通过Tool-Nodejs-Run来运行Nodejs代码了。

上一篇下一篇

猜你喜欢

热点阅读