首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >找不到任何nodejs模块AWS弹性豆柄

找不到任何nodejs模块AWS弹性豆柄
EN

Stack Overflow用户
提问于 2022-09-12 23:09:05
回答 1查看 68关注 0票数 1

我正在尝试将我的快递服务器部署到AWS ElasticBean秸秆,但始终遇到模块找不到的问题。我使用CodeBuild和buildspec.yml来构建代码并将其转换为工件。

EB部署日志:

代码语言:javascript
复制
----------------------------------------
/var/log/web.stdout.log
----------------------------------------
Sep 12 22:54:02 ip-172-31-15-80 web: at Function.Module._load (node:internal/modules/cjs/loader:839:12)
Sep 12 22:54:02 ip-172-31-15-80 web: at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12) {
Sep 12 22:54:02 ip-172-31-15-80 web: code: 'MODULE_NOT_FOUND',
Sep 12 22:54:02 ip-172-31-15-80 web: requireStack: [ '/var/app/current/app.js' ]
Sep 12 22:54:02 ip-172-31-15-80 web: }
Sep 12 22:54:02 ip-172-31-15-80 web: node:internal/modules/cjs/loader:959
Sep 12 22:54:02 ip-172-31-15-80 web: throw err;
Sep 12 22:54:02 ip-172-31-15-80 web: ^
Sep 12 22:54:02 ip-172-31-15-80 web: Error: Cannot find module 'express'
Sep 12 22:54:02 ip-172-31-15-80 web: Require stack:
Sep 12 22:54:02 ip-172-31-15-80 web: - /var/app/current/app.js
Sep 12 22:54:02 ip-172-31-15-80 web: at Function.Module._resolveFilename (node:internal/modules/cjs/loader:956:15)
Sep 12 22:54:02 ip-172-31-15-80 web: at Function.Module._load (node:internal/modules/cjs/loader:804:27)
Sep 12 22:54:02 ip-172-31-15-80 web: at Module.require (node:internal/modules/cjs/loader:1028:19)
Sep 12 22:54:02 ip-172-31-15-80 web: at require (node:internal/modules/cjs/helpers:102:18)
Sep 12 22:54:02 ip-172-31-15-80 web: at Object.<anonymous> (/var/app/current/app.js:6:35)
Sep 12 22:54:02 ip-172-31-15-80 web: at Module._compile (node:internal/modules/cjs/loader:1126:14)
Sep 12 22:54:02 ip-172-31-15-80 web: at Object.Module._extensions..js (node:internal/modules/cjs/loader:1180:10)
Sep 12 22:54:02 ip-172-31-15-80 web: at Module.load (node:internal/modules/cjs/loader:1004:32)
Sep 12 22:54:02 ip-172-31-15-80 web: at Function.Module._load (node:internal/modules/cjs/loader:839:12)
Sep 12 22:54:02 ip-172-31-15-80 web: at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12) {
...

Buildspec.yml

代码语言:javascript
复制
version: 0.2

batch:
  fast-fail: true
phases:
  install:
    runtime-versions:
      nodejs: 16
  build:
    commands:
      - npm run build
artifacts:
  type: zip
  files:
    - "**/*"
  base-directory: build

任何帮助都将不胜感激。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2022-09-12 23:42:52

您需要在构建步骤中复制node_modules。我这样做的方法是添加一个post_build pahase。

代码语言:javascript
复制
post_build:
    commands:
        - cp -R node_modules/ dist/node_modules
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/73696099

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档