快速安装 Node.js 并初始化 Express 应用

  1. 安装 Node Version Manager
  • 下载并运行安装脚本
$ curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.6/install.sh | bash 
$ nvm --version

Note: On Linux, after running the install script, if you get nvm: command not found, simply close your current terminal, open a new terminal, and try verifying again. If it doesn't work, your system may not have a .bash_profile file where the command is set up. Simply create one with touch ~/.bash_profile and run the install script again. If the above doesn't fix the problem, open your .bash_profile and add the following line of code: source ~/.bashrc

  1. Install the latest long-term support (LTS) version
$ nvm install --lts
$ node --version
$ npm --version
  1. 查看已安装的 node 版本
$ nvm ls
  1. 使用某一版本的 node
$ nvm use 8.9.1
Now using node v8.9.1 (npm v5.5.1)
$ nvm use 4.6.0
Now using node v4.6.0 (npm v2.15.9)
  1. 设置默认 Node 版本
nvm alias default 8.9.1
  1. 安装 nodemon
$ npm install -g nodemon
  1. 安装 Express application generator
$ npm install -g express-generator
  1. 初始化 Express 项目
$ git clone https://github.com/bioxfu/WebDev
$ bash WebDev/express_init.sh
  1. 运行 Express app
$ nodenom
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容