12

Dockerfile runs RUN npm run build which runs vue-cli-service build. After some time, I get an error from .eslintrc.js:

Failed to load plugin 'vue' declared in '.eslintrc.js': createRequire is not a function. Build does not get completed because of this issue.

This issue does not occur if I run npm run build manually. Why do I get this issue and How can I resolve it?

.eslintrc.js:

module.exports = {
  root: true,
  env: {
    node: true
  },
  extends: ['plugin:vue/essential', '@vue/airbnb', '@vue/prettier'],
  rules: {
    'no-console': process.env.NODE_ENV === 'production' ? 'error' : 'off',
    'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off',
    'consistent-return': 0,
    'import/extensions': 0,
    'import/no-extraneous-dependencies': 0,
    'no-param-reassign': 0,
    'no-alert': 0,
    'no-unused-expressions': 0,
    'no-shadow': 0,
    'no-return-assign': 0
  },
  plugins: ['prettier'],
  parserOptions: {
    parser: 'babel-eslint'
  }
};

package.json:

{
  "name": "web",
  "version": "0.1.0",
  "private": true,
  "scripts": {
    "build": "vue-cli-service build",
    "lint": "vue-cli-service lint",
    "start": "vue-cli-service serve"
  },
  "dependencies": {
    "axios": "^0.19.2",
    "core-js": "^3.6.5",
    "date-fns": "^2.14.0",
    "humps": "^2.0.1",
    "izitoast": "^1.4.0",
    "lamejs": "^1.2.0",
    "pug-plain-loader": "^1.0.0",
    "register-service-worker": "^1.7.1",
    "sass": "^1.26.5",
    "sass-loader": "^8.0.2",
    "vue": "^2.6.11",
    "vue-resource": "^1.5.1",
    "vue-router": "^3.2.0",
    "vuex": "^3.4.0",
  },
  "devDependencies": {
    "@vue/cli-plugin-babel": "^4.3.1",
    "@vue/cli-plugin-eslint": "^4.3.1",
    "@vue/cli-plugin-pwa": "^4.3.1",
    "@vue/cli-service": "^4.3.1",
    "@vue/eslint-config-airbnb": "^5.0.2",
    "@vue/eslint-config-prettier": "^6.0.0",
    "babel-eslint": "^10.1.0",
    "compression-webpack-plugin": "^4.0.0",
    "eslint": "^7.0.0",
    "eslint-plugin-prettier": "^3.1.3",
    "eslint-plugin-vue": "^6.2.2",
    "expose-loader": "^0.7.5",
    "material-design-icons-iconfont": "^5.0.1",
    "node-sass": "^4.14.1",
    "vue-cli-plugin-vuetify": "^2.0.5",
    "vue-template-compiler": "^2.6.11",
    "vuetify-loader": "^1.4.3",
    "webpack-bundle-analyzer": "^3.8.0"
  }
}

1
  • 4
    I got this fixed by upgrading from Node10 to Node12 Commented Jun 8, 2020 at 13:40

1 Answer 1

2

Have you run npm run install to install all the dependencies before running npm run build?

If yes, maybe you need to add some code into your .eslintrc file:

"parser": "vue-eslint-parser",

Finally, you may also need to add the npm package named 'prettier' to make it works.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.