nuxt-modules / eslint

ESLint module for Nuxt.js
MIT License
160 stars 15 forks source link

Cannot find module '@nuxtjs/eslint-module' inside of Docker container #37

Closed on3dd closed 4 years ago

on3dd commented 4 years ago

Hi there,

I'm trying to Dockerize my new Nuxt app and getting following error:

Cannot find module '@nuxtjs/eslint-module'

Complete error stack:

Removing intermediate container c80055ef7787
 ---> 233e243ee4a9
Step 8/11 : RUN npm run build
 ---> Running in ff252419c4b4

> nuxt-sign-in-form@1.0.0 build /app
> nuxt build

 WARN  Module @nuxtjs/eslint-module not found. Please ensure @nuxtjs/eslint-module is in devDependencies and installed. HINT: During build step, for npm/yarn, NODE_ENV=production or --production should NOT be used.

 FATAL  Cannot find module '@nuxtjs/eslint-module'
Require stack:
- /app/node_modules/@nuxt/core/dist/core.js
- /app/node_modules/@nuxt/cli/dist/cli-index.js
- /app/node_modules/@nuxt/cli/dist/cli.js
- /app/node_modules/nuxt/bin/nuxt.js

  Error: Cannot find module '@nuxtjs/eslint-module'
  Require stack:
  - node_modules/@nuxt/core/dist/core.js
  - node_modules/@nuxt/cli/dist/cli-index.js
  - node_modules/@nuxt/cli/dist/cli.js
  - node_modules/nuxt/bin/nuxt.js
  at Resolver.requireModule (node_modules/@nuxt/core/dist/core.js:609:31)
  at ModuleContainer.addModule (node_modules/@nuxt/core/dist/core.js:174:38)
  at promise.then (node_modules/@nuxt/utils/dist/utils.js:1837:43)
  at process._tickCallback (internal/process/next_tick.js:68:7)
  at Function.Module.runMain (internal/modules/cjs/loader.js:834:11)

   ╭───────────────────────────────────────────────────────╮
   │                                                       │
   │   ✖ Nuxt Fatal Error                                  │
   │                                                       │
   │   Error: Cannot find module '@nuxtjs/eslint-module'   │
   │   Require stack:                                      │
   │   - /app/node_modules/@nuxt/core/dist/core.js         │
   │   - /app/node_modules/@nuxt/cli/dist/cli-index.js     │
   │   - /app/node_modules/@nuxt/cli/dist/cli.js           │
   │   - /app/node_modules/nuxt/bin/nuxt.js                │
   │                                                       │
   ╰───────────────────────────────────────────────────────╯

^[[22;188Rnpm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! nuxt-sign-in-form@1.0.0 build: `nuxt build`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the nuxt-sign-in-form@1.0.0 build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2020-08-04T08_11_19_768Z-debug.log
The command '/bin/sh -c npm run build' returned a non-zero code: 1

nuxt.config.js:

...,
buildModules: [
    // Doc: https://github.com/nuxt-community/eslint-module
    '@nuxtjs/eslint-module',
    '@nuxtjs/vuetify',
  ],
...

Dockerfile:

FROM node:10-alpine

ENV APP_ROOT /app
ENV NODE_ENV production

RUN mkdir ${APP_ROOT}
WORKDIR ${APP_ROOT}
ADD . ${APP_ROOT}

RUN npm install
RUN npm run build

ENV HOST 0.0.0.0
EXPOSE 3000

CMD ["npm", "run", "start"]

Project repository: https://github.com/on3dd/nuxt-sign-in-form

Any idea what I might be doing wrong here?

on3dd commented 4 years ago

Found the source of the error. For some reason, inside the container, the project is built only if there is @nuxtjs/eslint-module set in dependencies instead of devDependencies. Why does it work this way?

gaowhen commented 4 years ago

Do you notice HINT: During build step, for npm/yarn, NODE_ENV=production or --production should NOT be used. in the WARN?

Seems like ENV NODE_ENV production in your Dockerfile makes it doesn't install devDependencies. So during build process, @nuxtjs/eslint-module cannot be found.

on3dd commented 4 years ago

@gaowhen Oops, missed that. Thanks, the problem was solved.

Ravimanickavasagam commented 1 year ago

how did you solve this .. pls reply

Ravimanickavasagam commented 1 year ago

@on3dd

mvrska commented 1 year ago

how did you solve this .. pls reply

read the thread