Search code examples
javascriptvue.jswebpackvue-cli

vue-cli - cannot build for development mode


I have a .env file in my project

-public
-src
-.env.development.local

package.json

{
    "name": "my-website",
    "version": "0.1.0",
    "scripts": {
      "serve": "vue-cli-service serve",
      "build": "vue-cli-service build --mode development",
      "lint": "vue-cli-service lint"
    }
  }

When I run npm run build for the first time, it works.

When I run it after that, it shows error:

my-website@0.1.0 build: `vue-cli-service build --mode development`

When I dig into the logs

13 verbose stack Error: my-website@0.1.0 build: `vue-cli-service build --mode development`
13 verbose stack Exit status 1

After I delete the public folder, it suddenly works


Solution

  • After I update the outputDir from public to build, it works.

    vue.config.js

    module.exports = {
      outputDir : 'build',
    }