node:hello world!

nvmnodeJs版本管理工具,管理nodejs版本和npm版本
nodeJsreactNative开发过程中所需要的代码库。
npm:是随同nodeJs一起安装的包管理工具,npm管理对应nodeJs的第三方插件

依赖关系

nvm、nodejs、npm的关系:

  1. nvm管理构建nodejs和对应的npmnpm管理对应nodejs的第三方插件
  2. 一个reactNative项目只包含一个nodejsnpm,npmnodejs是配套关系,一对一的关系。

nvm构建reactNavite的关系图

To install or update nvm, you can use the [install script][2] using cURL:

安装

1
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.8/install.sh | bash

or Wget:

1
wget -qO- https://raw.githubusercontent.com/creationix/nvm/v0.33.8/install.sh | bash

The script clones the nvm repository to ~/.nvm and adds the source line to your profile (~/.bash_profile, ~/.zshrc, ~/.profile, or ~/.bashrc).

1
2
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
1
2
3
4
5
6
7
# 安装 node 指定版本
nvm i 8.11.1
# 切换指定版本
nvm use 8.11.1
# 查看版本
npm -v
node -v

更换源

1
2
3
4
5
6
7
8
9
10
# 临时使用淘宝源
npm --registry https://registry.npm.taobao.org install node-red-contrib-composer@latest
# 全局配置切换到淘宝源
npm config set registry https://registry.npm.taobao.org
# 全局配置切回到官方源
npm config set registry http://www.npmjs.org
# 检测是否切换到了淘宝源
npm info underscore
# 查看源
npm config get registry

Simple App

阮一峰教程

1
2
cnpm i -g webpack
cnpm i -g webpack-dev-server

参考