madlabsinc / mevn-cli

Light speed setup for MEVN(Mongo Express Vue Node) Apps
https://mevn.surge.sh
MIT License
825 stars 152 forks source link

Invalid nuxt config module injection during launch #172

Closed haxzie closed 4 years ago

haxzie commented 4 years ago

Describe the bug The serve command fails due to syntax errors in nuxt.config.js file. This occurs due to redundant module injection happening while configuring PWA dependencies. A simple check to see if the project is already configured for PWA before installing the dependencies and modifying the nuxt.config.js can solve this problem.

To Reproduce Run the following commands are ran on a Ubuntu 20.04 system.

$ mevn init test-app
   > Nuxt-js
 # Yes for all with PWA support

$ cd test-app
$ mevn serve
    > client

The initial run will be successful, however subsequent runs will fail. with the following error.

$ mevn serve
   > client
 FATAL  Invalid or unexpected token

  '@nuxtjs/eslint-module',
  ^

  SyntaxError: Invalid or unexpected token
  at Object.Module._extensions..js (internal/modules/cjs/loader.js:1159:10

Expected behavior All the subsequent run of the serve command should execute without fail. The launch script should not append the modules if the app is already configured once for PWA, with necessary modules in nuxt.config.js.

Screenshots Screenshot from 2020-05-10 11-02-07

Environment Info

Environment Info:

  System:
    OS: Linux 5.4 Ubuntu 20.04 LTS (Focal Fossa)
    CPU: (4) x64 Intel(R) Core(TM) i7-5600U CPU @ 2.60GHz
  Binaries:
    Node: 13.5.0 - ~/.nvm/versions/node/v13.5.0/bin/node
    Yarn: 1.21.1 - ~/.nvm/versions/node/v13.5.0/bin/yarn
    npm: 6.13.4 - ~/.nvm/versions/node/v13.5.0/bin/npm
  Browsers:
    Firefox: 75.0
  npmGlobalPackages:
    mevn-cli: 1.7.5

Additional context Setting a simple flag in the .mevnrc after configuring PWA for the initial time will be helpful to check and prevent re-configuring the app for PWA for subsequent runs.