Webpack compiled vue file always reported an error Module parse failed: Unexpected token (3:0)

problem description

webpack compiles vue file and keeps reporting errors
ERROR in. / src/app.vue 3:0
Module parse failed: Unexpected token (3:0)
You may need an appropriate loader to handle this file type.
|
|

< template >
| < div class= "example" > {{msg}} < / div >
| < / template >
@. / src/index.js 4:0-28 8:18-21

clipboard.png

the environmental background of the problems and what methods you have tried

I read a lot of answers on the Internet, but I didn"t solve them

related codes

/ / Please paste the code text below (do not replace the code with pictures)

const path = require ("path");
const VueLoaderPlugin = require (" vue-loader/lib/plugin");
module.exprots = {

mode: "development",
entry: path.join(__dirname, "src/index.js"),
output: {
    path: path.resolve(__dirname, "dist"),
    filename: "bundle.js",
},
module: {
    rules: [
        {
            test: /\.vue$/,
            loader: "vue-loader",
            exclude: file => (
                /node_modules/.test(file) &&
                !/\.vue\.js/.test(file)
            )
        },
        {
            test: /\.js$/,
            loader: "babel-loader"
        },
        {
            test: /\.css$/,
            loader: "style-loader!css-loader"
        }
    ]
},
plugins: [
    new VueLoaderPlugin()
]

}

related codes

app.vue

< template >
< div class= "example" > {{msg}} < / div >
< / template >

< script >
export default {
data () {

return {
  msg: "Hello world!"
}

}
}
< / script >

< style >
.example {
color: red;
}
< / style >

related codes

package.json file
{
"name": "vue",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {

"dev": "webpack --mode=development",
"test": "echo \"Error: no test specified\" && exit 1"

},
"author": "",
"license": "ISC",
"dependencies": {

"vue": "^2.5.22"

},
"devDependencies": {

"babel-loader": "^8.0.5",
"css-loader": "^2.1.0",
"node-pre-gyp": "^0.12.0",
"style-loader": "^0.23.1",
"vue-loader": "^15.5.1",
"vue-template-compiler": "^2.5.22",
"webpack": "^4.28.4",
"webpack-cli": "^3.2.1"

}
}

related codes

index.js
import Vue from "vue";
import App from ". / app.vue";

new Vue ({

)
el: "-sharproot",
components: { App },
template: "<App/>"

});

Apr.30,2022

webpack.config.js misspelling--!:

should be module.exports = instead of module.exprots =

so, your webpack configuration is not used at all.

it is recommended that you install a code spell checker for your editor.


put

in webapck.config.js
exclude: file => (
    /node_modules/.test(file) &&
    !/\.vue\.js/.test(file)
)

get rid of.


  

is module.exports exporting this module to other modules to quote, it is exports, misspelled words, and this kind of commonly used code, generally, you only need what copy already has. Don't manually type it yourself to avoid typing wrong. You can't check where the problem lies in most of the day.
and newspaper reading error messages are caused by incorrect loader you installed, and some loader you do not install. Check which loader,webpack.config.js are used in the code and see

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e5aaf0-455c8.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e5aaf0-455c8.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?