首页 > 解决方案 > 找不到模块 xlsx

问题描述

我有一个 nodejs 项目 docker build,它在 Azure Pipeline 上构建得很好。但是大约 10 天前,构建输出更改为多了一行,我不明白它的原因。它位于底部的“+ xlsx@0.17.0”行(在下面的输出中以粗体显示)。

从输出没有附加行到现在,代码中没有任何变化。

docker 文件或构建定义中也没有任何更改。在 package.json 中,我引用了“xlsx:^0.14.5”。即使我将其更改为“xlsx:0.14.5”,输出日志也会包含“+ xlsx@0.17.0”,这让我感到困惑。它不应该尝试安装该版本吗?

注意:我问的原因是因为当这个 docker 镜像被推送到 Amazon ECS 时,它会抛出“Module not found 'xlsx'”错误。

谢谢您的帮助!

found 10 vulnerabilities (2 low, 4 moderate, 4 high)
  run `npm audit fix` to fix them, or `npm audit` for details

> nodemon@1.19.4 postinstall /srv/node_modules/nodemon
> node bin/postinstall || exit 0

Love nodemon? You can now support the project via the open collective:
 > https://opencollective.com/nodemon/donate

npm WARN pg-cursor@2.7.1 requires a peer of pg@^8 but none is installed. You must install peer dependencies yourself.
npm WARN swagger-ui-express@4.1.6 requires a peer of express@>=4.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@2.3.2 (node_modules/jest-haste-map/node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@2.3.2: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.13 (node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.13: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})

***+ xlsx@0.17.0***

added 663 packages from 361 contributors and updated 2 packages in 11.462s

39 packages are looking for funding
  run `npm fund` for details

fixed 1 of 10 vulnerabilities in 1394 scanned packages
  4 vulnerabilities required manual review and could not be updated
  4 package updates for 5 vulnerabilities involved breaking changes
  (use `npm audit fix --force` to install breaking changes; or refer to `npm audit` for steps to fix these manually)
Removing intermediate container 4c02dbafa75c
 ---> c010404a92cb
Step 9/30 : ADD . .
 ---> d1925852f28b

标签: node.jsdockernpmxlsx

解决方案


我无法发表评论,所以我会在这里问:

您是否将package-lock.json文件添加到 docker 映像中?您可能不是,这就是 npm 安装更新版本软件包的原因。

如果它当前在您的开发环境中工作,这可能会修复错误。如果没有,你是如何导入包的?


推荐阅读