I am learning vue-loader, and according to the method in the video,
I created a new file
1 index.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<app></app>
<script src="build.js"></script>
</body>
</html>
2 main.js
import Vue from "vue";
3 webpack.config.js
module.exports={
entry:'./main.js',
output:{
path:__dirname,
filename:"build.js"
}
}
4 Empty App.vue file
5 After passing npm init, scripts was changed to the execution command
6 Downloaded webpck webpack-dev-server through cnpm install webpack webpack-dev-server
After finally passing npm run dev, the error is reported as follows
ERROR in ./main.js
Module not found: Error: Can't resolve 'vue' in '....vue-loader-demo'
@./main.js 1:0 -22
@multi ./~/_webpack-dev-server@2.4.5@webpack-dev-server/client?http://localhost:8081 webpack/hot/dev-server ./main.js
webpack:Failed to compile.
Kneel down and thank you all, waiting online
missing vue
npm isntall vue --save-dev
How to compile vue with webpack? Have you installed vue-loader
What is the configuration of webpack? ? ?
How to compile vue?
Get a vue loader
vue is not installed.
First try the following two steps:
1. Install vue-loader dependency locally
After successful installation, the package.json and devDependencies items in the vue-loader-demo folder will display vue-loader and the corresponding version number, for example:
2. Add the configuration of vue-loader in webpack
vue is not installed
Question: Is there a package.json? Is there vue in the dependency?