我通过 CodePipeline/CodeBuild 运行以下构建规范
version: 0.2
phases:
install:
runtime-versions:
nodejs: 18
pre_build:
commands:
- echo Installing source NPM dependencies...
- cd webConsole
- npm install -g yarn
- yarn install
build:
commands:
- echo Build started on $(date)
- yarn build
post_build:
commands:
- aws s3 cp --recursive --acl public-read ./out s3://<S3_BUCKET>
- aws s3 cp --acl public-read --cache-control="max-age=0, no-cache, no-store, must-revalidate" ./out/index.html s3://<S3_BUCKET
- aws cloudfront create-invalidation --distribution-id <CLOUDFRONT DISTRO> --paths /*
artifacts:
baseDirectory: build
files:
- "**/*"
cache:
paths:
- node_modules/**/*
我在本地运行相同的步骤,并且在相同版本的节点上运行良好。我想知道是否有人在管道的 CodeBuild 阶段看到过同样的事情。安装工作正常,但我在构建阶段遇到以下错误
./src/components/Login.jsx
Module not found: Can't resolve './misc/CustomCheckbox'
https://nextjs.org/docs/messages/module-not-found
我已检查我的导入是否使用了正确的大小写,并且 CustomCheckbox 只是一个样式化的 MUI 复选框。,
nextjs 构建是一个独立构建,具有以下配置
/**
* @type {import('next').NextConfig}
*/
const nextConfig = {
output: "export",
trailingSlash: true,
optimizeFonts: false,
};
module.exports = nextConfig;
对于文件:
git mv filename to Filename
对于文件夹:
我也有同样的。我可以毫无问题地在本地运行构建, 但在 github 中我遇到了“模块未找到错误”。我与同一技术堆栈上的其他 2 个项目进行了比较,它们构建得很好。
所以事实证明,如果
git
发生了更改,case
不会跟踪文件夹/文件的更改。就我而言,我将 Components
文件夹重命名为 components
文件夹,但未对其进行跟踪。