https://www.npmjs.com/package/npm
源加速
设置
1 | echo "registry = https://registry.npm.taobao.org">>~/.npmrc |
查看当前源
1 | npm config get registry |
使用
全局安装(-g)
typescript
1 | npm install -g typescript |
/opt/node/bin/tsc -> /opt/node/lib/node_modules/typescript/bin/tsc
/opt/node/bin/tsserver -> /opt/node/lib/node_modules/typescript/bin/tsserver
- typescript@4.7.3
added 1 package from 1 contributor in 2.252s
卸载
1 | npm uninstall -g typescript |
i
是install
的简写-g
是全局安装,不带-g
会安装在个人文件夹-S
与--save
的简写,安装包信息会写入dependencies
中;生产阶段,项目运行时的依赖-D
与--save-dev
的简写,安装包写入devDependencies
中;开发阶段,只在开发阶段起作用,例如代码提示工具
后台运行
pm2
1 | npm install pm2 -g |
pm2 start run.js –name my-api # 命名进程
pm2 list # 显示所有进程状态
pm2 monit # 监视所有进程
pm2 logs # 显示所有进程日志
pm2 stop all # 停止所有进程
pm2 restart all # 重启所有进程
pm2 reload all # 0秒停机重载进程 (用于 NETWORKED 进程)
pm2 stop 0 # 停止指定的进程
pm2 restart 0 # 重启指定的进程
pm2 startup # 产生 init 脚本 保持进程活着
pm2 web # 运行健壮的 computer API endpoint (http://localhost:9615)
pm2 delete 0 # 杀死指定的进程
pm2 delete all # 杀死全部进程
1 | cat >run.js<<EOF |
vue-tsc: not found
1 | ❯ npm install -D vue-tsc |
> zinc-search@0.3.6 build
> vue-tsc –noEmit && vite buildvite v2.9.18 building for production…
✓ 296 modules transformed.
dist/assets/KFOmCnqEu92Fr1Mu4mxM.f2abf7fb.woff 19.87 KiB
dist/assets/KFOkCnqEu92Fr1MmgVxIIzQ.34e9582c.woff 19.96 KiB
dist/assets/KFOlCnqEu92Fr1MmSU5fBBc-.bf14c7d7.woff 19.94 KiB
dist/assets/KFOlCnqEu92Fr1MmWUlfBBc-.e0fd57c0.woff 19.93 KiB
dist/assets/KFOlCnqEu92Fr1MmEU9fBBc-.9ce7f3ac.woff 20.06 KiB
dist/assets/KFOlCnqEu92Fr1MmYUtfBBc-.f6537e32.woff 19.95 KiB
dist/assets/flUhRq6tzZclQEJ-Vdg-IuiaDsNcIhQ8tQ.83be7b2f.woff2 125.35 KiB
dist/assets/flUhRq6tzZclQEJ-Vdg-IuiaDsNa.fd84f88b.woff 161.05 KiB
dist/assets/jsoneditor-icons.45c98bf0.svg 30.74 KiB
dist/index.html 0.42 KiB
dist/assets/Error404.5abc079a.js 0.53 KiB / gzip: 0.37 KiB
dist/assets/MainLayout.c10cd2e1.css 0.31 KiB / gzip: 0.18 KiB
dist/assets/MainLayout.8ebc7735.js 14.18 KiB / gzip: 5.14 KiB
dist/assets/index.3c97601c.css 225.83 KiB / gzip: 40.01 KiB
dist/assets/index.4d6be492.js 2002.85 KiB / gzip: 573.13 KiB(!) Some chunks are larger than 500 KiB after minification. Consider:
- Using dynamic import() to code-split the application
- Use build.rollupOptions.output.manualChunks to improve chunking: https://rollupjs.org/guide/en/#outputmanualchunks
- Adjust chunk size limit for this warning via build.chunkSizeWarningLimit.