npm中文文档
1.npm安装
- 安装node.js(包含 npm)
- 加入环境变量,通常安装node.js的时候会自动添加到系统环境变量中。
- cmd中运行npm -v 显示出版本号就说明安装成功。
2.设置 npm 缓存路径
- windows下:
1
2npm config set prefix "C:/Program Files/nodejs/npm_global"
npm config set cache "C:/Program Files/nodejs/npm_cache" - Linux\Mac 下:
1
2npm config set prefix "~/nodejs/npm_global"
npm config set cache "~/nodejs/npm_cache"如果出现安装了某个全局模块但是运行时提示“bash: ncu: command not found”
那么请把npm_global目录添加到环境变量中
3.设置下载来源(镜像),加速下载
1 | npm config set registry "https://registry.npm.taobao.org/" |
4.npm 模块更新
- 升级插件 npm-check-updates
1
npm install -g npm-check-updates
- 到需要升级的package.json同级目录下运行ncu命令(ncu 是 npm-check-updates 的缩写命令)
如果有需要更新的版本则先根据提示运行ncu -u更新package.json中的版本信息,然后再运行npm install进行安装升级。如果在使用git bash运行ncu命令时出现这个问题:
那么请使用cmd,重新运行此命令。
4.1在右击菜单中添加在此处打开cmd
- 把下面的代码复制到记事本保存为 xxx.reg
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Directory\background\shell\cmd_here]
@="在此处打开命令行"
"Icon"="cmd.exe"
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Directory\background\shell\cmd_here\command]
@="\"C:\\Windows\\System32\\cmd.exe\""
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Folder\shell\cmdPrompt]
@="在此处打开命令行"
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Folder\shell\cmdPrompt\command]
@="\"C:\\Windows\\System32\\cmd.exe\" \"cd %1\""
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Directory\shell\cmd_here]
@="在此处打开命令行"
"Icon"="cmd.exe"
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Directory\shell\cmd_here\command]
@="\"C:\\Windows\\System32\\cmd.exe\"" - 双击运行,OK!
5.npm运用示例(安装HexoEditor)
- HexoEditor, 一个写 Hexo 非常好用的 Markdown 编辑器 HexoEditor
1
2
3
4git clone https://github.com/zhuzhuyule/HexoEditor.git
cd HexoEditor
npm install
npm start
- 如果在运行npm -install的时候报错出现这个问题提示找不到这个包:
- 那么就打开 HexoEditor 目录下的的package.json文件,将文件中的这一行删除(先跳过这个包):
- 然后到目录node_modules下clone [email protected]版本 进行手动安装:
1
2
3git clone https://github.com/Moeditor/js-sequence-diagrams.git
cd js-sequence-diagrams
npm install - 把这个模块安装上以后就可以正常预览使用标记语言书写的博客咯~