У меня Codepipeline отлично работает с
- Извлечь исходные файлы из Github
- Создайте рабочий сайт Next.js на Codebuild и выведите его на S3
- Согласно Codedeploy, есть успех при развертывании файла S3 Elastic Beanstalk.
Однако у меня возникают проблемы при попытке запуска Elastic Beanstalk.
Oct 26 15:55:23 ip-xxx-xx-xx-xxx web: code: 'MODULE_NOT_FOUND',
Oct 26 15:55:23 ip-xxx-xx-xx-xxx web: requireStack: [ '/var/app/current/node_modules/.bin/next' ]
Oct 26 15:55:23 ip-xxx-xx-xx-xxx web: }
Oct 26 15:55:23 ip-xxx-xx-xx-xxx web: npm ERR! code ELIFECYCLE
Oct 26 15:55:23 ip-xxx-xx-xx-xxx web: npm ERR! errno 1
Oct 26 15:55:23 ip-xxx-xx-xx-xxx web: npm ERR! [email protected] start: `next start`
Oct 26 15:55:23 ip-xxx-xx-xx-xxx web: npm ERR! Exit status 1
Моя команда запуска - next start
, но похоже, что узловых модулей нет. Когда я распаковываю вывод в S3, я вижу полную сборку next.js, так что с этой частью все в порядке. Кажется, я не могу найти решение, почему он не работает на ELB - есть идеи, где что-то идет не так? Ниже мой buildspec.yml для справки.
version: 0.2
phases:
install:
#If you use the Ubuntu standard image 2.0 or later, you must specify runtime-versions.
#If you specify runtime-versions and use an image other than Ubuntu standard image 2.0, the build fails.
runtime-versions:
nodejs: 12
commands:
- yarn
build:
commands:
- npx next build
artifacts:
files:
- '**/*'
ОБНОВЛЕНИЕ
Оказывается, все было на месте, но следующая команда не была распознана. Решением было использовать абсолютный путь в моей стартовой команде: node_modules/next/dist/bin/next start
.