当前位置:   article > 正文

微信小程序引入node_modules依赖

微信小程序引入node

微信小程序不支持直接读取node_modules

首先在目录文件夹下cmd输入npm init命令

  1. D:\小程序\project\calendar\calendar_1>npm init
  2. This utility will walk you through creating a package.json file.
  3. It only covers the most common items, and tries to guess sensible defaults.
  4. See `npm help init` for definitive documentation on these fields
  5. and exactly what they do.
  6. Use `npm install <pkg>` afterwards to install a package and
  7. save it as a dependency in the package.json file.
  8. Press ^C at any time to quit.
  9. version: (1.0.0)
  10. description:
  11. entry point: (app.js)
  12. test command:
  13. git repository:
  14. keywords:
  15. author:
  16. license: (ISC)
  17. About to write to D:\小程序\project\calendar\calendar_1\package.json:
  18. {
  19. "name": "calendar_1",
  20. "version": "1.0.0",
  21. "description": "",
  22. "main": "app.js",
  23. "dependencies": {
  24. "accepts": "^1.3.8",
  25. "agentkeepalive": "^4.5.0",
  26. "ajv": "^6.12.6",
  27. "arg": "^4.1.3",
  28. "array-flatten": "^1.1.1",
  29. "asn1": "^0.2.6",
  30. "assert-plus": "^1.0.0",
  31. "asynckit": "^0.4.0",
  32. "aws-sign2": "^0.7.0",
  33. "aws4": "^1.12.0",
  34. "axios": "^0.21.4",
  35. "base64-js": "^1.5.1",
  36. "bcrypt-pbkdf": "^1.0.2",
  37. "bignumber.js": "^9.0.0",
  38. "bluebird": "^3.7.2",
  39. "body-parser": "^1.20.1",
  40. "bson": "^4.7.2",
  41. "buffer": "^5.7.1",
  42. "buffer-equal-constant-time": "^1.0.1",
  43. "buffer-from": "^1.1.2",
  44. "bytes": "^3.1.2",
  45. "call-bind": "^1.0.5",
  46. "caseless": "^0.12.0",
  47. "clone": "^2.1.2",
  48. "combined-stream": "^1.0.8",
  49. "content-disposition": "^0.5.4",
  50. "content-type": "^1.0.5",
  51. "cookie": "^0.5.0",
  52. "cookie-signature": "^1.0.6",
  53. "core-util-is": "^1.0.3",
  54. "dashdash": "^1.14.1",
  55. "debug": "^2.6.9",
  56. "define-data-property": "^1.1.1",
  57. "delayed-stream": "^1.0.0",
  58. "depd": "^2.0.0",
  59. "destroy": "^1.2.0",
  60. "diff": "^4.0.2",
  61. "ecc-jsbn": "^0.1.2",
  62. "ecdsa-sig-formatter": "^1.0.11",
  63. "ee-first": "^1.1.1",
  64. "encodeurl": "^1.0.2",
  65. "escape-html": "^1.0.3",
  66. "etag": "^1.8.1",
  67. "express": "^4.18.2",
  68. "extend": "^3.0.2",
  69. "extsprintf": "^1.3.0",
  70. "fast-deep-equal": "^3.1.3",
  71. "fast-json-stable-stringify": "^2.1.0",
  72. "finalhandler": "^1.2.0",
  73. "follow-redirects": "^1.15.3",
  74. "forever-agent": "^0.6.1",
  75. "form-data": "^2.3.3",
  76. "forwarded": "^0.2.0",
  77. "fresh": "^0.5.2",
  78. "function-bind": "^1.1.2",
  79. "get-intrinsic": "^1.2.2",
  80. "getpass": "^0.1.7",
  81. "gopd": "^1.0.1",
  82. "har-schema": "^2.0.0",
  83. "har-validator": "^5.1.5",
  84. "has-property-descriptors": "^1.0.1",
  85. "has-proto": "^1.0.1",
  86. "has-symbols": "^1.0.3",
  87. "has-tostringtag": "^1.0.0",
  88. "hasown": "^2.0.0",
  89. "http-errors": "^2.0.0",
  90. "http-signature": "^1.2.0",
  91. "humanize-ms": "^1.2.1",
  92. "iconv-lite": "^0.4.24",
  93. "ieee754": "^1.2.1",
  94. "inherits": "^2.0.4",
  95. "ipaddr.js": "^1.9.1",
  96. "is-regex": "^1.1.4",
  97. "is-stream": "^2.0.1",
  98. "is-typedarray": "^1.0.0",
  99. "isarray": "^1.0.0",
  100. "isstream": "^0.1.2",
  101. "jsbn": "^0.1.1",
  102. "json-bigint": "^1.0.0",
  103. "json-schema": "^0.4.0",
  104. "json-schema-traverse": "^0.4.1",
  105. "json-stringify-safe": "^5.0.1",
  106. "jsonwebtoken": "^8.5.1",
  107. "jsprim": "^1.4.2",
  108. "jwa": "^1.4.1",
  109. "jws": "^3.2.2",
  110. "lodash": "^4.17.21",
  111. "lodash.clonedeep": "^4.5.0",
  112. "lodash.includes": "^4.3.0",
  113. "lodash.isboolean": "^3.0.3",
  114. "lodash.isinteger": "^4.0.4",
  115. "lodash.isnumber": "^3.0.3",
  116. "lodash.isplainobject": "^4.0.6",
  117. "lodash.isstring": "^4.0.1",
  118. "lodash.merge": "^4.6.2",
  119. "lodash.once": "^4.1.1",
  120. "lodash.set": "^4.3.2",
  121. "lodash.unset": "^4.5.2",
  122. "long": "^4.0.0",
  123. "make-error": "^1.3.6",
  124. "media-typer": "^0.3.0",
  125. "merge-descriptors": "^1.0.1",
  126. "methods": "^1.1.2",
  127. "mime": "^1.6.0",
  128. "mime-db": "^1.52.0",
  129. "mime-types": "^2.1.35",
  130. "ms": "^2.1.3",
  131. "mysql": "^2.18.1",
  132. "negotiator": "^0.6.3",
  133. "oauth-sign": "^0.9.0",
  134. "object-inspect": "^1.13.1",
  135. "on-finished": "^2.4.1",
  136. "parseurl": "^1.3.3",
  137. "path-to-regexp": "^0.1.7",
  138. "performance-now": "^2.1.0",
  139. "process-nextick-args": "^2.0.1",
  140. "protobufjs": "^6.11.4",
  141. "proxy-addr": "^2.0.7",
  142. "psl": "^1.9.0",
  143. "punycode": "^2.3.1",
  144. "qs": "^6.5.3",
  145. "range-parser": "^1.2.1",
  146. "raw-body": "^2.5.1",
  147. "readable-stream": "^2.3.7",
  148. "request": "^2.88.2",
  149. "request-promise": "^4.2.6",
  150. "request-promise-core": "^1.1.4",
  151. "retry": "^0.12.0",
  152. "safe-buffer": "^5.1.2",
  153. "safer-buffer": "^2.1.2",
  154. "sax": "^1.3.0",
  155. "semver": "^5.7.2",
  156. "send": "^0.18.0",
  157. "serve-static": "^1.15.0",
  158. "set-function-length": "^1.1.1",
  159. "setprototypeof": "^1.2.0",
  160. "side-channel": "^1.0.4",
  161. "source-map": "^0.6.1",
  162. "source-map-support": "^0.5.21",
  163. "sqlstring": "^2.3.1",
  164. "sshpk": "^1.18.0",
  165. "statuses": "^2.0.1",
  166. "stealthy-require": "^1.1.1",
  167. "string_decoder": "^1.1.1",
  168. "tcb-admin-node": "^1.23.0",
  169. "toidentifier": "^1.0.1",
  170. "tough-cookie": "^2.5.0",
  171. "ts-node": "^8.10.2",
  172. "tslib": "^1.14.1",
  173. "tunnel-agent": "^0.6.0",
  174. "tweetnacl": "^0.14.5",
  175. "type-is": "^1.6.18",
  176. "typescript": "^5.3.2",
  177. "undici-types": "^5.26.5",
  178. "unpipe": "^1.0.0",
  179. "uri-js": "^4.4.1",
  180. "url": "^0.11.3",
  181. "util-deprecate": "^1.0.2",
  182. "utils-merge": "^1.0.1",
  183. "uuid": "^3.4.0",
  184. "vary": "^1.1.2",
  185. "verror": "^1.10.0",
  186. "wx-server-sdk": "^2.6.3",
  187. "xml2js": "^0.4.23",
  188. "xmlbuilder": "^11.0.1",
  189. "yn": "^3.1.1"
  190. },
  191. "devDependencies": {},
  192. "scripts": {
  193. "test": "echo \"Error: no test specified\" && exit 1"
  194. },
  195. "author": "",
  196. "license": "ISC"
  197. }
  198. Is this OK? (yes)
  199. D:\小程序\project\calendar\calendar_1>npm install
  200. removed 181 packages in 2m
  201. D:\小程序\project\calendar\calendar_1>

以上为cmd下操作过程,基本一路enter即可。

最后removed 181 packages in 2m是应为之前在calendar_1下就有node_modules。

然后到微信开发者工具下:

构建完成:

会生成如下文件夹:

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/寸_铁/article/detail/898081
推荐阅读
相关标签
  

闽ICP备14008679号