notes/config/nodejs/npm.md

26 lines
501 B
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# npm config
使用系统 npm 目录会报权限错误,建议使用自定义的目录。
```bash
export NODE_PATH="$NODE_PATH:$HOME/.local/npm/lib/node_modules"
export PATH=$HOME/.local/npm/bin:$PATH
```
由于npm 安装太慢所以使用cnmp。
```bash
npm install -g cnpm --registry=https://registry.npm.taobao.org
npm config set registry https://registry.npm.taobao.org
```
使用cnmp安装react
```bash
cnpm install -g create-react-app
create-react-app my-app
cd my-app/
npm start
```