Blogger Information
Blog 21
fans 0
comment 0
visits 9406
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
node.js基础npm 包的基本操作
P粉116103988
Original
834 people have browsed it

node.js基础包 npm操作练习

  1. <?php
  2. Windows PowerShell
  3. 版权所有 (C) Microsoft Corporation。保留所有权利。
  4. 尝试新的跨平台 PowerShell https://aka.ms/pscore6
  5. 目录: E:\PHP学习\js学习
  6. Mode LastWriteTime Length Name
  7. ---- ------------- ------ ----
  8. d----- 2022-07-27 13:35 0722
  9. d----- 2022-08-03 11:11 0802
  10. PS E:\PHP学习\js学习> cd 0802
  11. // ls 查看当前位置有哪些文档
  12. PS E:\PHP学习\js学习\0802> ls
  13. // cd 0802 进入到 0802文档
  14. 目录: E:\PHP学习\js学习\0802
  15. Mode LastWriteTime Length Name
  16. d----- 2022-08-03 10:39 node_modules
  17. d----- 2022-08-03 11:11 npm
  18. -a---- 2022-08-03 10:12 0 demo.js
  19. -a---- 2022-08-03 10:09 274 demo1.html
  20. -a---- 2022-08-03 10:39 782 package-lock.json
  21. -a---- 2022-08-03 10:39 267 package.json
  22. //查看node 版本信息
  23. PS E:\PHP学习\js学习\0802\npm> node -v
  24. v16.16.0
  25. PS E:\PHP学习\js学习\0802\npm> clg
  26. clg : 无法将“clg”项识别为 cmdlet、函数、脚本文件或可运行程序的名称。请检查名称的拼写,如果包括路径,请确
  27. 保路径正确,然后再试一次。
  28. 所在位置 行:1 字符: 1
  29. + clg
  30. + ~~~
  31. + CategoryInfo : ObjectNotFound: (clg:String) [], CommandNotFoundException
  32. + FullyQualifiedErrorId : CommandNotFoundException
  33. PS E:\PHP学习\js学习\0802\npm> node demo
  34. throw err;
  35. ^
  36. Error: Cannot find module 'E:\PHP学习\js学习\0802\npm\demo'
  37. at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)
  38. at Function.Module._load (node:internal/modules/cjs/loader:778:27)
  39. at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:77:12)
  40. at node:internal/main/run_main_module:17:47 {
  41. code: 'MODULE_NOT_FOUND',
  42. requireStack: []
  43. }
  44. // 生成默认的包和配置文件package.json
  45. PS E:\PHP学习\js学习\0802\npm> npm init -y
  46. npm WARN config global `--global`, `--local` are deprecated. Use `--location=global` instead.
  47. Wrote to E:\PHP学习\js学习\0802\npm\package.json:
  48. {
  49. "name": "npm",
  50. "description": "",
  51. "scripts": {
  52. "test": "echo \"Error: no test specified\" && exit 1"
  53. },
  54. "author": "",
  55. "license": "ISC"
  56. PS E:\PHP学习\js学习\0802\npm> npm config set registry https://registry.npm.taobao.org
  57. //将包 lodash 安装到本项目: npm i lodas
  58. PS E:\PHP学习\js学习\0802\npm> npm i lodash
  59. npm WARN config global `--global`, `--local` are deprecated. Use `--location=global` instead.
  60. added 1 package in 4s
  61. npm WARN config global `--global`, `--local` are deprecated. Use `--location=global` instead.
  62. // 查看本项目路径: npm root
  63. E:\PHP学习\js学习\0802\npm\node_modules
  64. //查看全局路径: npm root -g
  65. PS E:\PHP学习\js学习\0802\npm> npm root -g
  66. npm WARN config global `--global`, `--local` are deprecated. Use `--location=global` instead.
  67. npm WARN config global `--global`, `--local` are deprecated. Use `--location=global` instead.
  68. C:\Users\asus\AppData\Roaming\npm\node_modules
  69. PS E:\PHP学习\js学习\0802\npm> npm i axios -D -g
  70. npm WARN config global `--global`, `--local` are deprecated. Use `--location=global` instead.
  71. changed 8 packages in 2s
  72. //查看安装的包(本项目)
  73. PS E:\PHP学习\js学习\0802\npm> list
  74. list : 无法将“list”项识别为 cmdlet、函数、脚本文件或可运行程序的名称。请检查名称的拼写,如果包括路径,请
  75. 所在位置 行:1 字符: 1
  76. + list
  77. + ~~~~
  78. + CategoryInfo : ObjectNotFound: (list:String) [], CommandNotFoundException
  79. + FullyQualifiedErrorId : CommandNotFoundException
  80. //查看全局安装的包:npm list
  81. PS E:\PHP学习\js学习\0802\npm> npm list
  82. npm@1.0.0 E:\PHP学习\js学习\0802\npm
  83. //查看全局安装的包:npm list -g
  84. PS E:\PHP学习\js学习\0802\npm> npm list -g
  85. npm WARN config global `--global`, `--local` are deprecated. Use `--location=global` instead.
  86. npm WARN config global `--global`, `--local` are deprecated. Use `--location=global` instead.
  87. C:\Users\asus\AppData\Roaming\npm
  88. ├── axios@0.27.2
  89. ├── lodash@4.17.21
  90. └── ncu@0.2.1
  91. PS E:\PHP学习\js学习\0802\npm> npm outdated
  92. npm WARN config global `--global`, `--local` are deprecated. Use `--location=global` instead.
  93. npm WARN config global `--global`, `--local` are deprecated. Use `--location=global` instead.
  94. npm WARN config global `--global`, `--local` are deprecated. Use `--location=global` instead.
  95. npm ERR! code EEXIST
  96. npm ERR! path C:\Users\asus\AppData\Roaming\npm\ncu
  97. npm ERR! EEXIST: file already exists
  98. npm ERR! File exists: C:\Users\asus\AppData\Roaming\npm\ncu
  99. npm ERR! Remove the existing file and try again, or run npm
  100. npm ERR! A complete log of this run can be found in:
  101. npm ERR! C:\Users\asus\AppData\Local\npm-cache\_logs\2022-08-03T03_58_47_449Z-debug-0.log
  102. PS E:\PHP学习\js学习\0802\npm> ncu -u lodash
  103. ncu : 无法加载文件 C:\Users\asus\AppData\Roaming\npm\ncu.ps1,因为在此系统上禁止运行脚本。有关详细信息,请
  104. 参阅 https:/go.microsoft.com/fwlink/?LinkID=135170 中的 about_Execution_Policies
  105. 所在位置 行:1 字符: 1
  106. + ~~~
  107. + CategoryInfo : SecurityError: (:) [],PSSecurityException
  108. + FullyQualifiedErrorId : UnauthorizedAccess
  109. PS E:\PHP学习\js学习\0802\npm> npm list -g
  110. npm WARN config global `--global`, `--local` are deprecated. Use `--location=global` instead.
  111. npm WARN config global `--global`, `--local` are deprecated. Use `--location=global` instead.
  112. ├── axios@0.27.2
  113. ├── lodash@4.17.21
  114. └── ncu@0.2.1
  115. //删除已安装的全局的包 ncu
  116. PS E:\PHP学习\js学习\0802\npm> npm uninstall ncu -g
  117. npm WARN config global `--global`, `--local` are deprecated. Use `--location=global` instead.
  118. removed 75 packages, and audited 1 package in 1s
  119. found 0 vulnerabilities
  120. PS E:\PHP学习\js学习\0802\npm> npm list -g
  121. npm WARN config global `--global`, `--local` are deprecated. Use `--location=global` instead.
  122. C:\Users\asus\AppData\Roaming\npm
  123. ├── axios@0.27.2
  124. └── lodash@4.17.21
  125. PS E:\PHP学习\js学习\0802\npm> npm uninstall lodash -g
  126. npm WARN config global `--global`, `--local` are deprecated. Use `--location=global` instead.
  127. removed 1 package, and audited 1 package in 2s
  128. PS E:\PHP学习\js学习\0802\npm> npm list -g
  129. npm WARN config global `--global`, `--local` are deprecated. Use `--location=global` instead.
  130. npm WARN config global `--global`, `--local` are deprecated. Use `--location=global` instead.
  131. C:\Users\asus\AppData\Roaming\npm
  132. PS E:\PHP学习\js学习\0802\npm> npm list
  133. npm WARN config global `--global`, `--local` are deprecated. Use `--location=global` instead.
  134. npm@1.0.0 E:\PHP学习\js学习\0802\npm
  135. └── lodash@4.17.21
  136. //将更新插件安装到全局 ncu:npm-check-updates
  137. PS E:\PHP学习\js学习\0802\npm> npm i npm-check-updates -g
  138. npm WARN config global `--global`, `--local` are deprecated. Use `--location=global` instead.
  139. npm WARN config global `--global`, `--local` are deprecated. Use `--location=global` instead.
  140. added 280 packages in 14s
  141. PS E:\PHP学习\js学习\0802\npm> npm list -g
  142. npm WARN config global `--global`, `--local` are deprecated. Use `--location=global` instead.
  143. npm WARN config global `--global`, `--local` are deprecated. Use `--location=global` instead.
  144. C:\Users\asus\AppData\Roaming\npm
  145. ├── axios@0.27.2
  146. └── npm-check-updates@16.0.5
  147. PS E:\PHP学习\js学习\0802\npm>
  148. ?>
Correcting teacher:PHPzPHPz

Correction status:qualified

Teacher's comments:
Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post