Node.js/npm/指令:修订间差异
来自康健生活
创建页面,内容为“== 安装路径 == === 路径 === {{shc_out|<syntaxhighlight lang="bash"> npm root -g</syntaxhighlight>|<syntaxhighlight lang="text"> /usr/local/lib/node_modules</syntaxhighlight>|$}} === 环境 === {{shc_out|<syntaxhighlight lang="bash"> npm config ls</syntaxhighlight>|<syntaxhighlight lang="text"> ; cli configs metrics-registry = "https://registry.npm.taobao.org/" scope = "" user-agent = "npm/6.14.5 node/v12.18.1 linux x64" ; userconfig /home/kangjian/.npmrc…” |
|||
| (未显示同一用户的4个中间版本) | |||
| 第32行: | 第32行: | ||
{{shc|<syntaxhighlight lang="bash"> | {{shc|<syntaxhighlight lang="bash"> | ||
npm config set prefix *</syntaxhighlight>|$}} | npm config set prefix *</syntaxhighlight>|$}} | ||
== 命令 == | |||
=== config === | |||
{{Shc_out|<syntaxhighlight lang="bash"> | |||
npm config edit</syntaxhighlight>|<syntaxhighlight lang="bash">;;;; | |||
; npm userconfig file: /Users/kangjian/.npmrc | |||
// ... | |||
... | |||
</syntaxhighlight>|$|/home/kangkk}} | |||
// | |||
{{Shc_out|<syntaxhighlight lang="bash"> | |||
npm who am i</syntaxhighlight>|<syntaxhighlight lang="bash">kangjian | |||
</syntaxhighlight>|$|/home/kangkk}} | |||
// | |||
{{Shc_out|<syntaxhighlight lang="bash"> | |||
npm config set strict-ssl false</syntaxhighlight>|<syntaxhighlight lang="bash"> | |||
</syntaxhighlight>|$|/home/kangkk}} | |||
// | |||
{{Shc_out|<syntaxhighlight lang="bash"> | |||
npm cache clean--force</syntaxhighlight>|<syntaxhighlight lang="bash"> | |||
</syntaxhighlight>|$|/home/kangkk}} | |||
=== version === | |||
修复或小的模块逻辑更改。 | |||
{{shc|<syntaxhighlight lang="bash"> | |||
npm version patch</syntaxhighlight>|$|/home/kangkk}} | |||
功能逻辑变更。 | |||
{{shc|<syntaxhighlight lang="bash"> | |||
npm version minor</syntaxhighlight>|$|/home/kangkk}} | |||
大版本改动,不再向下兼容。 | |||
{{shc|<syntaxhighlight lang="bash"> | |||
npm version major</syntaxhighlight>|$|/home/kangkk}} | |||
=== ls === | |||
查看命令。如查看某组件的版本信息。 | |||
{{Shc_out|<syntaxhighlight lang="bash"> | |||
npm ls express</syntaxhighlight>|<syntaxhighlight lang="bash"> | |||
kangkk-check-imported-file@0.0.6 /Users/kangjian/360/dora/td-deadfile | |||
└── express@4.18.2 | |||
</syntaxhighlight>|$|/home/kangkk}} | |||
除此之外还可以通过添加额外的参数检查深度。 | |||
{{Shc_out|<syntaxhighlight lang="bash"> | |||
npm ls --depth=0</syntaxhighlight>|<syntaxhighlight lang="bash"> | |||
kangkk-check-imported-file@0.0.6 /Users/kangjian/360/dora/td-deadfile | |||
├── @semantic-release/changelog@6.0.1 | |||
├── @semantic-release/git@10.0.1 | |||
... | |||
├── table@5.4.6 | |||
├── util@0.12.5 | |||
└── yargs@14.2.3 | |||
</syntaxhighlight>|$|/home/kangkk}} | |||
== 包升级工具 == | |||
=== ls === | |||
{{shc_out|<syntaxhighlight lang="bash"> | |||
npm ls vue</syntaxhighlight>|<syntaxhighlight lang="text"> | |||
ask-go-pc@1.0.0 /mnt/d/gitee/k/ask-go-pc | |||
├─┬ nuxt@2.14.6 | |||
│ ├─┬ @nuxt/builder@2.14.6 | |||
│ │ └─┬ @nuxt/vue-app@2.14.6 | |||
│ │ └── vue@2.6.12 deduped | |||
│ └─┬ @nuxt/core@2.14.6 | |||
│ └─┬ @nuxt/vue-renderer@2.14.6 | |||
│ └── vue@2.6.12 deduped | |||
└── vue@2.6.12 | |||
</syntaxhighlight>|kangkk@LAPTOP-S5B1JMCV:/mnt/d/gitee/k/ask-go-pc$}} | |||
== install== | |||
{{shc|<syntaxhighlight lang="bash"> | |||
npm install kangwuyi/git-repo.git | |||
npm install github:kangwuyi/git-repo.git | |||
npm install git+https://github.com/kangwuyi/git-repo.git | |||
npm install git+ssh://github.com/kangwuyi/git-repo.git</syntaxhighlight>|$|/home/kangkk}} | |||
== view == | |||
{{Shc_out|<syntaxhighlight lang="bash"> | |||
npm view think-view versions</syntaxhighlight>|<syntaxhighlight lang="bash"> | |||
[ | |||
'1.0.0', '1.0.1', | |||
'1.0.2', '1.0.3', | |||
'1.0.4', '1.0.5', | |||
'1.0.7', '1.0.8', | |||
'1.0.9', '1.0.10', | |||
'1.0.11', '1.0.12', | |||
'1.0.13' | |||
] | |||
</syntaxhighlight>|$|/home/kangkk}} | |||
{{Shc_out|<syntaxhighlight lang="bash"> | |||
npm view think-view versions --json</syntaxhighlight>|<syntaxhighlight lang="bash"> | |||
[ | |||
"1.0.0", | |||
"1.0.1", | |||
"1.0.2", | |||
"1.0.3", | |||
"1.0.4", | |||
"1.0.5", | |||
"1.0.7", | |||
"1.0.8", | |||
"1.0.9", | |||
"1.0.10", | |||
"1.0.11", | |||
"1.0.12", | |||
"1.0.13" | |||
] | |||
</syntaxhighlight>|$|/home/kangkk}} | |||
{{Shc_out|<syntaxhighlight lang="bash"> | |||
npm view think-view@1.0.13 engines</syntaxhighlight>|<syntaxhighlight lang="bash"> | |||
{ node: '>=6.0.0' } | |||
</syntaxhighlight>|$|/home/kangkk}} | |||
== package-lock == | |||
禁止生成 package-lock.json 文件。 | |||
{{shc|<syntaxhighlight lang="bash"> | |||
npm config set package-lock false</syntaxhighlight>|$|/home/kangkk}} | |||
=== legacy-peer-deps === | |||
{{shc|<syntaxhighlight lang="bash"> | |||
npm i --legacy-peer-deps</syntaxhighlight>|$|/home/kangkk}} | |||