在Heroku日志中收到此错误:
2020-08-20T03:03:13.626572+00:00 heroku[web.1]: Starting process with command `yarn start`
2020-08-20T03:03:16.057916+00:00 app[web.1]: yarn run v1.21.1
2020-08-20T03:03:16.136668+00:00 app[web.1]: $ nuxt start yarn start
2020-08-20T03:03:16.951614+00:00 app[web.1]:
2020-08-20T03:03:16.951649+00:00 app[web.1]: FATAL No build files found in /app/yarn/.nuxt/dist/server.
2020-08-20T03:03:16.951650+00:00 app[web.1]: Use either `nuxt build` or `builder.build()` or start nuxt in development mode.
2020-08-20T03:03:16.951650+00:00 app[web.1]:
2020-08-20T03:03:16.951651+00:00 app[web.1]: Use either `nuxt build` or `builder.build()` or start nuxt in development mode.
2020-08-20T03:03:16.951651+00:00 app[web.1]: at VueRenderer._ready (node_modules/@nuxt/vue-renderer/dist/vue-renderer.js:4257:13)
2020-08-20T03:03:16.951651+00:00 app[web.1]: at async Server.ready (node_modules/@nuxt/server/dist/server.js:607:5)
2020-08-20T03:03:16.951652+00:00 app[web.1]: at async Nuxt._init (node_modules/@nuxt/core/dist/core.js:689:7)
2020-08-20T03:03:16.951652+00:00 app[web.1]:
2020-08-20T03:03:16.982859+00:00 app[web.1]: 7[r[999;999H[6n8
2020-08-20T03:03:16.982861+00:00 app[web.1]: ╭─────────────────────────────────────────────────────────────────────────────────────╮
2020-08-20T03:03:16.982862+00:00 app[web.1]: │ │
2020-08-20T03:03:16.982862+00:00 app[web.1]: │ ✖ Nuxt Fatal Error │
2020-08-20T03:03:16.982863+00:00 app[web.1]: │ │
2020-08-20T03:03:16.982863+00:00 app[web.1]: │ Error: No build files found in /app/yarn/.nuxt/dist/server. │
2020-08-20T03:03:16.982864+00:00 app[web.1]: │ Use either `nuxt build` or `builder.build()` or start nuxt in development mode. │
2020-08-20T03:03:16.982864+00:00 app[web.1]: │ │
2020-08-20T03:03:16.982864+00:00 app[web.1]: ╰─────────────────────────────────────────────────────────────────────────────────────╯
2020-08-20T03:03:16.982865+00:00 app[web.1]:
2020-08-20T03:03:17.006698+00:00 app[web.1]: error Command failed with exit code 1.
2020-08-20T03:03:17.006980+00:00 app[web.1]: info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
2020-08-20T03:03:17.095912+00:00 heroku[web.1]: Process exited with status 1
2020-08-20T03:03:17.150932+00:00 heroku[web.1]: State changed from starting to crashed
我可以在本地和容器中运行相同的Docker映像。该文件存在:
/app/yarn/.nuxt/dist/server
这是Dockerfile
FROM node:12.14.0-alpine
WORKDIR /app
COPY package*.json ./
RUN yarn install
COPY . .
ARG API_URL
ENV API_URL ${API_URL}
ARG API_URL_BROWSER
ENV API_URL_BROWSER ${API_URL_BROWSER}
ENV HOST 0.0.0.0
RUN yarn build
EXPOSE 3000
ENTRYPOINT [ "yarn", "start" ]
在本地使用相同的Dockerfile不会有任何麻烦。任何想法表示赞赏!