Node.JS 可以直接命令行中使用 node 命令 node xxx.JS 启动, 使用 webstorm 方式启动或用 pm2 方式使用命令 pm2 start xxx.JS 启动 Node.JS.
Node.JS 启动的方法如下:
1, 原始 node 命令
直接命令行中使用 node 命令
node xxx.JS
或者安装 nodemon, 使用 nodemon 启动方便在开发阶段热部署代码改动
NPM i nodemon -G
nodemon xxx.JS
2,webstorm 方式
webstorm 中, 需要执行的文件的上, 右键 ->run, 右上角出现 JS 文件, 点击下拉箭头 ->Edit Configurations.
选择 Node iterpreter,apply.
文件上右键 ->run.
即可使用 webstorm 中的内置控制台运行 Node.JS 文件.
3,pm2
全局安装 pm2
cnpm i pm2 -g
用 pm2 运行 Node.JS
pm2 start xxx.JS
pm2 以进程方式后台运行 node 文件.
来源: http://www.css88.com/qa/node-js/10727.html