node的npm常用命令演示

编辑: admin 分类: 电脑知识 发布时间: 2023-06-14 来源:互联网

node.js基本操作:

  1. 查看路径
  2. PS C:\Users\hao_z\Desktop\php> pwd
  3. Path
  4. ----
  5. C:\Users\hao_z\Desktop\php
  6. 查看版本
  7. PS C:\Users\hao_z\Desktop\php>node -v
  8. v16.13.0
  9. 切换目录
  10. PS C:\Users\hao_z\Desktop\php> cd 0403
  11. 运行文件 .js后缀可省略
  12. PS C:\Users\hao_z\Desktop\php\0403> node demo.js
  13. hello world
  14. 设置第三方模块国内镜像
  15. PS C:\Users\hao_z\Desktop\php\0403> npm config set registry https://registry.npm.taobao.org
  16. 建立包仓库:y为yes,默认选择,否则逐项配置
  17. PS C:\Users\hao_z\Desktop\php\0403>npm init -y
  18. 装置第三方包,install简写为i
  19. PS C:\Users\hao_z\Desktop\php\0403> npm i lodash
  20. added 1 package in 2s
  21. 卸载第三方包:uni
  22. PS C:\Users\hao_z\Desktop\php\0403> npm uni lodash
  23. removed 1 package, and audited 1 package in 711ms
  24. found 0 vulnerabilities
  25. 更新node.js版本
  26. PS C:\Users\hao_z\Desktop\php\0403> npm i npm-check-updates -g
  27. npm WARN deprecated @npmcli/move-file@2.0.1: This functionality has been moved to @npmcli/fs
  28. added 317 packages in 12s
  29. 查看全局包目录,g:global
  30. PS C:\Users\hao_z\Desktop\php\0403> npm root -g
  31. C:\Users\hao_z\AppData\Roaming\npm\node_modules
  32. 全局安装
  33. PS C:\Users\hao_z\Desktop\php\0403> npm i lodash -g
  34. added 1 package in 2s
  35. 全局卸载,全局包必须全局卸载
  36. PS C:\Users\hao_z\Desktop\php\0403> npm uni lodash -g
  37. removed 1 package, and audited 1 package in 804ms
  38. found 0 vulnerabilities
  39. 查看包仓库
  40. PS C:\Users\hao_z\Desktop\php\0403> npm list
  41. 0403@ C:\Users\hao_z\Desktop\php\0403
  42. └── lodash@4.17.21
  43. 查看全局包
  44. PS C:\Users\hao_z\Desktop\php\0403> npm list -g
  45. C:\Users\hao_z\AppData\Roaming\npm
  46. ├── express-generator@4.16.1
  47. ├── mkdirp@1.0.4
  48. └── npm-check-updates@16.10.0
  49. 安装生产依赖-S/开发依赖-D
  50. PS C:\Users\hao_z\Desktop\php\0403> npm i jquery -D
  51. added 1 package in 1s
总结:

fetch api前端应该会常用;node听说过,没用过,前面讲的模块不错,想用模块应该需要用node。

【本文由:高防服务器ip http://www.558idc.com/gfip.html 复制请保留原URL】