npm run serve 不适用于 Vue 项目“您可能需要适当的加载器来处理此文件类型”[重复]
Posted
技术标签:
【中文标题】npm run serve 不适用于 Vue 项目“您可能需要适当的加载器来处理此文件类型”[重复]【英文标题】:npm run serve not working on Vue Project "You may need an appropriate loader to handle this file type" [duplicate] 【发布时间】:2021-09-14 02:52:59 【问题描述】:这发生在我当前的项目中,然后我尝试删除 node_modules 并重新安装它,但它无论如何都不起作用 我尝试使用
创建一个新的vue create "newproject"
确保我的代码没有任何问题 在我的 vue-cli 版本上
@vue/cli 4.5.7
我试着开始一个新的
npm run serve
但错误仍然出现
> newproject@0.1.0 serve
> vue-cli-service serve
INFO Starting development server...
98% after emitting CopyPlugin
ERROR Failed to compile with 1 error 12:40:11 PM
error in ./node_modules/@vue/reactivity/dist/reactivity.esm-bundler.js
Module parse failed: Unexpected token (763:13)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
|
| class RefImpl
> _rawValue;
| _shallow;
| _value;
@ ./node_modules/@vue/runtime-core/dist/runtime-core.esm-bundler.js 1:0-233 2:0-216 2:0-216 2:0-216 2:0-216 2:0-216 2:0-216 2:0-216 2:0-216 2:0-216 2:0-216 2:0-216 2:0-216 2:0-216 2:0-216 2:0-216 2:0-216 2:0-216 2:0-216 2:0-216 16:4-17 40:4-17 107:13-18 108:32-37 115:16-21 1958:8-13 1962:13-23 1968:35-45 1970:16-21 1973:21-31 2071:19-25 2094:8-12 2135:8-13 2210:29-34 2557:27-30 2558:26-29 2559:28-31 2905:16-29 2912:16-29 3043:28-36 3362:41-56 3378:28-33 3463:8-15 3500:32-37 3647:27-32 3823:29-34 3951:12-25 3958:12-25 4568:17-22 4592:13-18 5173:26-32 5336:8-21 5340:8-21 5755:16-20 5761:12-16 6296:27-32 6328:12-19 6338:16-23 6356:93-100 6357:15-20 6767:60-75 6768:60-75 6769:60-75 6770:59-74 6847:16-21 6997:16-21 7150:21-28 7160:8-21 7161:134-149 7162:8-21 7210:30-39 7264:8-21 7266:8-21 7314:23-38 7334:46-55 7334:56-63 7389:14-24 7576:21-26 7586:21-31 7593:24-34 7596:21-31 7624:53-58 7630:52-57 7696:48-53
@ ./node_modules/@vue/runtime-dom/dist/runtime-dom.esm-bundler.js
@ ./node_modules/vue/dist/vue.runtime.esm-bundler.js
@ ./src/main.js
@ multi (webpack)-dev-server/client?http://192.168.1.218:8080&sockPath=/sockjs-node (webpack)/hot/dev-server.js ./src/main.js
我的新项目 package.json
"name": "newproject",
"version": "0.1.0",
"private": true,
"scripts":
"serve": "vue-cli-service serve",
"build": "vue-cli-service build",
"lint": "vue-cli-service lint"
,
"dependencies":
"babel-preset-es2015": "^6.24.1",
"core-js": "^3.6.5",
"vue": "^3.0.0"
,
"devDependencies":
"@vue/cli-plugin-babel": "~4.5.0",
"@vue/cli-plugin-eslint": "~4.5.0",
"@vue/cli-service": "~4.5.0",
"@vue/compiler-sfc": "^3.0.0",
"babel-eslint": "^10.1.0",
"eslint": "^6.7.2",
"eslint-plugin-vue": "^7.0.0"
,
"eslintConfig":
"root": true,
"env":
"node": true
,
"extends": [
"plugin:vue/vue3-essential",
"eslint:recommended"
],
"parserOptions":
"parser": "babel-eslint"
,
"rules":
,
"browserslist": [
"> 1%",
"last 2 versions",
"not dead"
]
【问题讨论】:
【参考方案1】:vue.config.js
transpileDependencies: ['@vue/reactivity'],
没问题
【讨论】:
以上是关于npm run serve 不适用于 Vue 项目“您可能需要适当的加载器来处理此文件类型”[重复]的主要内容,如果未能解决你的问题,请参考以下文章
vue项目启动时,npm run serve 和 npm run dev 的区别
在 vue 项目中运行 npm run serve 时出现问题
使用 vue/cli 运行 npm run serve 时出现问题