0

我的 NodeJS Lambda 在尝试使用时因此错误而失败nanoidor uuid

{
  "error": "Error",
  "cause": {
    "errorType": "Error",
    "errorMessage": "Package subpath './index.cjs' is not defined by \"exports\" in /var/task/node_modules/nanoid/package.json",
    "trace": [
      "Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: Package subpath './index.cjs' is not defined by \"exports\" in /var/task/node_modules/nanoid/package.json",
      "    at throwExportsNotFound (internal/modules/esm/resolve.js:290:9)",
      "    at packageExportsResolve (internal/modules/esm/resolve.js:513:3)",
      "    at resolveExports (internal/modules/cjs/loader.js:437:36)",
      "    at Function.Module._findPath (internal/modules/cjs/loader.js:477:31)",
      "    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:872:27)",
      "    at Function.Module._load (internal/modules/cjs/loader.js:730:27)",
      "    at Module.require (internal/modules/cjs/loader.js:957:19)",
      "    at require (internal/modules/cjs/helpers.js:88:18)",
      "    at /var/task/__index.js:39:45",
      "    at Object.__f4 [as getPaths] (/var/task/__index.js:58:6)"
    ]
  }
}

这是使用的代码:

import { nanoid } from 'nanoid'

const id = nanoid()

其他信息:

Runtime: nodejs14.x
nanoid: ^3.1.23
4

0 回答 0