vue.js - 错误 : Cannot find module '@vue/babel-preset-app'

标签 vue.js babeljs vue-cli-3

当我创建一个新的 vue 应用程序并运行服务器时,编译失败后出现错误。 有谁知道问题出在哪里?

这是我的终端和浏览器的屏幕截图。 Terminal vue.js error

main.js 文件

import Vue from 'vue'
import App from './App.vue'

Vue.config.productionTip = false

new Vue({
  render: h => h(App),
}).$mount('#app')

和 package.json 文件

{
  "name": "vuedemo",
  "version": "0.1.0",
  "private": true,
  "scripts": {
    "serve": "vue-cli-service serve",
    "build": "vue-cli-service build",
    "lint": "vue-cli-service lint"
  },
  "dependencies": {
    "core-js": "^2.6.5",
    "vue": "^2.6.10"
  },
  "devDependencies": {
    "@vue/cli-plugin-babel": "^3.7.0",
    "@vue/cli-plugin-eslint": "^3.7.0",
    "@vue/cli-service": "^3.7.0",
    "babel-eslint": "^10.0.1",
    "eslint": "^5.16.0",
    "eslint-plugin-vue": "^5.0.0",
    "vue-template-compiler": "^2.5.21"
  },
  "eslintConfig": {
    "root": true,
    "env": {
      "node": true
    },
    "extends": [
      "plugin:vue/essential",
      "eslint:recommended"
    ],
    "rules": {},
    "parserOptions": {
      "parser": "babel-eslint"
    }
  },
  "postcss": {
    "plugins": {
      "autoprefixer": {}
    }
  },
  "browserslist": [
    "> 1%",
    "last 2 versions"
  ]
}

最佳答案

我在运行这个命令后解决了这个问题。 npm install @vue/babel-preset-app --save-dev

然后它抛给我这个错误 模块构建失败(来自 ./node_modules/@vue/cli-plugin-babel/node_modules/babel-loader/lib/index.js)

我启动了以下命令 npm install -D babel-loader @babel/core @babel/preset-env webpack

它给了我一个新的错误 无法解析加载器:vue-style-loader

之后我运行 npm install vue-style-loader

它又给了我另一个错误,这个 Error: Loading PostCSS Plugin failed: Cannot find module 'autoprefixer' 最后,我运行了下一个命令,npm i autoprefixer,它对我有用。

关于vue.js - 错误 : Cannot find module '@vue/babel-preset-app' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56197981/

相关文章:

vue.js - 如何将 ASP.NET Core 2.1 与 Vue CLI 3 集成?

javascript - Vue 模板不更新

javascript - [Vue 警告] : Error in render: "TypeError: Cannot read property ' paid' of null"

html - 如何使 Vuetify v-card-text 单行?

javascript - "react doesn' t 存在”在 Node.js 命令提示符中

javascript - Browserify 和 ES6/ES2015 类(babel 编译器)

javascript - 如何在 Windows PhpStorm 中安装和使用 Babel 和 watchers?

javascript - Vue cli 3 项目别名 src 到 @ 或 ~/不工作

vue.js - Vue-Cli : 'title' option for htmlWebpackPlugin does not work

javascript - 一个很好的 vue 网格替代方案,而不是使用 vue infinite loader