M
M
Maxim Boyko2021-07-23 01:10:09
Vue.js
Maxim Boyko, 2021-07-23 01:10:09

How to fix an error when building a vue app?

Generally I receive an error:
import { createApp } from "vue";
^^^^^^
SyntaxError: Cannot use import statement outside a module
The error occurs only during the build, if you start the server everything is fine, putting "type":"module" in package.json is not an option, as a result there will be even more errors, generally how to solve it?
package.json:

{
  "name": "web-visit-averito",
  "version": "0.1.0",
  "private": true,
  "scripts": {
    "serve": "vue-cli-service serve --open",
    "build": "vue-cli-service build",
    "lint": "vue-cli-service lint"
  },
  "dependencies": {
    "animate.css": "^4.1.1",
    "core-js": "^3.6.5",
    "vue": "^3.0.0",
    "vue-router": "^4.0.0-0",
    "vuex": "^4.0.0-0"
  },
  "devDependencies": {
    "@vue/cli-plugin-babel": "~4.5.0",
    "@vue/cli-plugin-eslint": "~4.5.0",
    "@vue/cli-plugin-router": "~4.5.0",
    "@vue/cli-plugin-vuex": "~4.5.0",
    "@vue/cli-service": "~4.5.0",
    "@vue/compiler-sfc": "^3.0.0",
    "@vue/eslint-config-prettier": "^6.0.0",
    "babel-eslint": "^10.1.0",
    "eslint": "^6.7.2",
    "eslint-plugin-prettier": "^3.3.1",
    "eslint-plugin-vue": "^7.0.0",
    "node-sass": "^4.12.0",
    "prettier": "^2.2.1",
    "sass-loader": "^8.0.2"
  },
  "eslintConfig": {
    "root": true,
    "env": {
      "node": true
    },
    "extends": [
      "plugin:vue/vue3-essential",
      "eslint:recommended",
      "@vue/prettier"
    ],
    "parserOptions": {
      "parser": "babel-eslint"
    },
    "rules": {}
  },
  "browserslist": [
    "> 1%",
    "last 2 versions",
    "not dead"
  ]
}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Red_Devi1, 2021-07-23
@Red_Devi1

Try

npm install --save-dev @babel/core @babel/node @babel/preset-env

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question