当我尝试在服务器上运行应用程序时,出现错误:找不到模块“/usr/src/nuxt-app/nuxt”。我没有更改 dockerfile 或 circleci 配置中的任何内容。它之前一直在工作,我不知道发生了什么。图像由 circleci 构建。在本地不使用 docker 一切正常。我该怎么办?
错误:
throw err;
^
Error: Cannot find module '/usr/src/nuxt-app/nuxt'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:880:15)
at Function.Module._load (internal/modules/cjs/loader.js:725:27)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:72:12)
at internal/main/run_main_module.js:17:47 {
code: 'MODULE_NOT_FOUND',
requireStack: []
}
Dockerfile:
FROM node:lts-alpine
RUN mkdir -p /usr/src/nuxt-app
WORKDIR /usr/src/nuxt-app
RUN apk update && apk upgrade
RUN apk add python make g++
ADD . /usr/src/nuxt-app/
RUN npm install
RUN npm run build
EXPOSE 5002
CMD [ "nuxt", "start" ]
circleci config.yml:
version: 2.1
orbs:
docker: circleci/docker@1.5.0
node: circleci/node@4.1.0
workflows:
build-deploy:
jobs:
- deploy:
context:
- docker
requires:
- build
filters:
branches:
only: master
jobs:
deploy:
machine: true
steps:
- checkout
- docker/install-docker-tools
- run:
name: Login to Docker
command: docker login -u=$DOCKER_LOGIN -p=$DOCKER_PASSWORD registry.xxx.com
- docker/build:
image: yyy
registry: registry.xxx.com
tag: latest
- docker/push:
image: yyy
registry: registry.xxx.com
tag: latest