微信小程序引入node_modules依赖

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

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

D:\小程序\project\calendar\calendar_1>npm init
This utility will walk you through creating a package.json file.
It only covers the most common items, and tries to guess sensible defaults.

See `npm help init` for definitive documentation on these fields
and exactly what they do.

Use `npm install ` afterwards to install a package and
save it as a dependency in the package.json file.

Press ^C at any time to quit.
version: (1.0.0)
description:
entry point: (app.js)
test command:
git repository:
keywords:
author:
license: (ISC)
About to write to D:\小程序\project\calendar\calendar_1\package.json:

{
  "name": "calendar_1",
  "version": "1.0.0",
  "description": "",
  "main": "app.js",
  "dependencies": {
    "accepts": "^1.3.8",
    "agentkeepalive": "^4.5.0",
    "ajv": "^6.12.6",
    "arg": "^4.1.3",
    "array-flatten": "^1.1.1",
    "asn1": "^0.2.6",
    "assert-plus": "^1.0.0",
    "asynckit": "^0.4.0",
    "aws-sign2": "^0.7.0",
    "aws4": "^1.12.0",
    "axios": "^0.21.4",
    "base64-js": "^1.5.1",
    "bcrypt-pbkdf": "^1.0.2",
    "bignumber.js": "^9.0.0",
    "bluebird": "^3.7.2",
    "body-parser": "^1.20.1",
    "bson": "^4.7.2",
    "buffer": "^5.7.1",
    "buffer-equal-constant-time": "^1.0.1",
    "buffer-from": "^1.1.2",
    "bytes": "^3.1.2",
    "call-bind": "^1.0.5",
    "caseless": "^0.12.0",
    "clone": "^2.1.2",
    "combined-stream": "^1.0.8",
    "content-disposition": "^0.5.4",
    "content-type": "^1.0.5",
    "cookie": "^0.5.0",
    "cookie-signature": "^1.0.6",
    "core-util-is": "^1.0.3",
    "dashdash": "^1.14.1",
    "debug": "^2.6.9",
    "define-data-property": "^1.1.1",
    "delayed-stream": "^1.0.0",
    "depd": "^2.0.0",
    "destroy": "^1.2.0",
    "diff": "^4.0.2",
    "ecc-jsbn": "^0.1.2",
    "ecdsa-sig-formatter": "^1.0.11",
    "ee-first": "^1.1.1",
    "encodeurl": "^1.0.2",
    "escape-html": "^1.0.3",
    "etag": "^1.8.1",
    "express": "^4.18.2",
    "extend": "^3.0.2",
    "extsprintf": "^1.3.0",
    "fast-deep-equal": "^3.1.3",
    "fast-json-stable-stringify": "^2.1.0",
    "finalhandler": "^1.2.0",
    "follow-redirects": "^1.15.3",
    "forever-agent": "^0.6.1",
    "form-data": "^2.3.3",
    "forwarded": "^0.2.0",
    "fresh": "^0.5.2",
    "function-bind": "^1.1.2",
    "get-intrinsic": "^1.2.2",
    "getpass": "^0.1.7",
    "gopd": "^1.0.1",
    "har-schema": "^2.0.0",
    "har-validator": "^5.1.5",
    "has-property-descriptors": "^1.0.1",
    "has-proto": "^1.0.1",
    "has-symbols": "^1.0.3",
    "has-tostringtag": "^1.0.0",
    "hasown": "^2.0.0",
    "http-errors": "^2.0.0",
    "http-signature": "^1.2.0",
    "humanize-ms": "^1.2.1",
    "iconv-lite": "^0.4.24",
    "ieee754": "^1.2.1",
    "inherits": "^2.0.4",
    "ipaddr.js": "^1.9.1",
    "is-regex": "^1.1.4",
    "is-stream": "^2.0.1",
    "is-typedarray": "^1.0.0",
    "isarray": "^1.0.0",
    "isstream": "^0.1.2",
    "jsbn": "^0.1.1",
    "json-bigint": "^1.0.0",
    "json-schema": "^0.4.0",
    "json-schema-traverse": "^0.4.1",
    "json-stringify-safe": "^5.0.1",
    "jsonwebtoken": "^8.5.1",
    "jsprim": "^1.4.2",
    "jwa": "^1.4.1",
    "jws": "^3.2.2",
    "lodash": "^4.17.21",
    "lodash.clonedeep": "^4.5.0",
    "lodash.includes": "^4.3.0",
    "lodash.isboolean": "^3.0.3",
    "lodash.isinteger": "^4.0.4",
    "lodash.isnumber": "^3.0.3",
    "lodash.isplainobject": "^4.0.6",
    "lodash.isstring": "^4.0.1",
    "lodash.merge": "^4.6.2",
    "lodash.once": "^4.1.1",
    "lodash.set": "^4.3.2",
    "lodash.unset": "^4.5.2",
    "long": "^4.0.0",
    "make-error": "^1.3.6",
    "media-typer": "^0.3.0",
    "merge-descriptors": "^1.0.1",
    "methods": "^1.1.2",
    "mime": "^1.6.0",
    "mime-db": "^1.52.0",
    "mime-types": "^2.1.35",
    "ms": "^2.1.3",
    "mysql": "^2.18.1",
    "negotiator": "^0.6.3",
    "oauth-sign": "^0.9.0",
    "object-inspect": "^1.13.1",
    "on-finished": "^2.4.1",
    "parseurl": "^1.3.3",
    "path-to-regexp": "^0.1.7",
    "performance-now": "^2.1.0",
    "process-nextick-args": "^2.0.1",
    "protobufjs": "^6.11.4",
    "proxy-addr": "^2.0.7",
    "psl": "^1.9.0",
    "punycode": "^2.3.1",
    "qs": "^6.5.3",
    "range-parser": "^1.2.1",
    "raw-body": "^2.5.1",
    "readable-stream": "^2.3.7",
    "request": "^2.88.2",
    "request-promise": "^4.2.6",
    "request-promise-core": "^1.1.4",
    "retry": "^0.12.0",
    "safe-buffer": "^5.1.2",
    "safer-buffer": "^2.1.2",
    "sax": "^1.3.0",
    "semver": "^5.7.2",
    "send": "^0.18.0",
    "serve-static": "^1.15.0",
    "set-function-length": "^1.1.1",
    "setprototypeof": "^1.2.0",
    "side-channel": "^1.0.4",
    "source-map": "^0.6.1",
    "source-map-support": "^0.5.21",
    "sqlstring": "^2.3.1",
    "sshpk": "^1.18.0",
    "statuses": "^2.0.1",
    "stealthy-require": "^1.1.1",
    "string_decoder": "^1.1.1",
    "tcb-admin-node": "^1.23.0",
    "toidentifier": "^1.0.1",
    "tough-cookie": "^2.5.0",
    "ts-node": "^8.10.2",
    "tslib": "^1.14.1",
    "tunnel-agent": "^0.6.0",
    "tweetnacl": "^0.14.5",
    "type-is": "^1.6.18",
    "typescript": "^5.3.2",
    "undici-types": "^5.26.5",
    "unpipe": "^1.0.0",
    "uri-js": "^4.4.1",
    "url": "^0.11.3",
    "util-deprecate": "^1.0.2",
    "utils-merge": "^1.0.1",
    "uuid": "^3.4.0",
    "vary": "^1.1.2",
    "verror": "^1.10.0",
    "wx-server-sdk": "^2.6.3",
    "xml2js": "^0.4.23",
    "xmlbuilder": "^11.0.1",
    "yn": "^3.1.1"
  },
  "devDependencies": {},
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "",
  "license": "ISC"
}


Is this OK? (yes)

D:\小程序\project\calendar\calendar_1>npm install

removed 181 packages in 2m

D:\小程序\project\calendar\calendar_1>

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

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

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

微信小程序引入node_modules依赖_第1张图片

构建完成:

微信小程序引入node_modules依赖_第2张图片

会生成如下文件夹:

微信小程序引入node_modules依赖_第3张图片

你可能感兴趣的:(微信小程序,小程序)