vue项目 npm dev 出现Cannot resolve module 'vue-html'
今天想学学vue
安装vue-cli后
vue init vuedemo
cd vuedemo
npm install
运行
npm run dev
出现
Listening at http://localhost:8080
webpack built c7fecbbc8f83a1bcf66e in 3539ms
Hash: c7fecbbc8f83a1bcf66e
Version: webpack 1.13.1
Time: 3539ms
Asset Size Chunks Chunk Names
app.js 22.3 kB 0 app
ERROR in Error: Child compilation failed:
Entry module not found: Error: Cannot resolve module 'vue-html' in /Users/holo to/WebstormProjects/vuedemo:
Error: Cannot resolve module 'vue-html' in /Users/holoto/WebstormProjects/vued emo
- compiler.js:88
[vuedemo]/[html-webpack-plugin]/lib/compiler.js:88:16
- Compiler.js:214 Compiler.<anonymous>
[vuedemo]/[webpack]/lib/Compiler.js:214:10
- Compiler.js:403
[vuedemo]/[webpack]/lib/Compiler.js:403:12
- Tapable.js:67 Compiler.next
[vuedemo]/[tapable]/lib/Tapable.js:67:11
- CachePlugin.js:40 Compiler.<anonymous>
[vuedemo]/[webpack]/lib/CachePlugin.js:40:4
- Tapable.js:71 Compiler.applyPluginsAsync
[vuedemo]/[tapable]/lib/Tapable.js:71:13
- Compiler.js:400 Compiler.<anonymous>
[vuedemo]/[webpack]/lib/Compiler.js:400:9
- Compilation.js:577 Compilation.<anonymous>
[vuedemo]/[webpack]/lib/Compilation.js:577:13
- Tapable.js:60 Compilation.applyPluginsAsync
[vuedemo]/[tapable]/lib/Tapable.js:60:69
- Compilation.js:572 Compilation.<anonymous>
[vuedemo]/[webpack]/lib/Compilation.js:572:10
- Tapable.js:60 Compilation.applyPluginsAsync
[vuedemo]/[tapable]/lib/Tapable.js:60:69
- Compilation.js:567 Compilation.<anonymous>
[vuedemo]/[webpack]/lib/Compilation.js:567:9
- Tapable.js:60 Compilation.applyPluginsAsync
[vuedemo]/[tapable]/lib/Tapable.js:60:69
- Compilation.js:563 Compilation.<anonymous>
[vuedemo]/[webpack]/lib/Compilation.js:563:8
- Tapable.js:60 Compilation.applyPluginsAsync
[vuedemo]/[tapable]/lib/Tapable.js:60:69
- Compilation.js:525 Compilation.seal
[vuedemo]/[webpack]/lib/Compilation.js:525:7
ERROR in Loader /Users/holoto/WebstormProjects/vuedemo/node_modules/eslint/lib/api.js didn't return a function
@ multi app
ERROR in Loader /Users/holoto/WebstormProjects/vuedemo/node_modules/eslint/lib/api.js didn't return a function
@ multi app
Child html-webpack-plugin for "index.html":
ERROR in Entry module not found: Error: Cannot resolve module 'vue-html' in /Users/holoto/WebstormProjects/vuedemo
webpack: bundle is now VALID.
package.json
{
"name": "vuedemo",
"version": "1.0.0",
"description": "A Vue.js project",
"private": true,
"scripts": {
"dev": "node build/dev-server.js",
"build": "node build/build.js",
"unit": "karma start test/unit/karma.conf.js --single-run",
"e2e": "node test/e2e/runner.js",
"test": "npm run unit && npm run e2e",
"lint": "eslint --ext .js,.vue src test/unit/specs test/e2e/specs"
},
"dependencies": {
"autoprefixer": "^6.3.6",
"babel-runtime": "^6.0.0",
"vue": "^1.0.21"
},
"devDependencies": {
"babel-core": "^6.0.0",
"babel-loader": "^6.0.0",
"babel-plugin-transform-runtime": "^6.0.0",
"babel-preset-es2015": "^6.0.0",
"babel-preset-stage-2": "^6.0.0",
"connect-history-api-fallback": "^1.1.0",
"css-loader": "^0.23.0",
"eslint": "^2.10.2",
"eslint-friendly-formatter": "^2.0.5",
"eslint-loader": "^1.3.0",
"eslint-plugin-html": "^1.3.0",
"eslint-config-airbnb-base": "^3.0.1",
"eslint-plugin-import": "^1.8.1",
"eventsource-polyfill": "^0.9.6",
"express": "^4.13.3",
"extract-text-webpack-plugin": "^1.0.1",
"file-loader": "^0.8.4",
"function-bind": "^1.0.2",
"html-webpack-plugin": "^2.8.1",
"http-proxy-middleware": "^0.12.0",
"json-loader": "^0.5.4",
"karma": "^0.13.15",
"karma-coverage": "^0.5.5",
"karma-mocha": "^0.2.2",
"karma-phantomjs-launcher": "^1.0.0",
"karma-sinon-chai": "^1.2.0",
"karma-sourcemap-loader": "^0.3.7",
"karma-spec-reporter": "0.0.24",
"karma-webpack": "^1.7.0",
"lolex": "^1.4.0",
"mocha": "^2.4.5",
"chai": "^3.5.0",
"sinon": "^1.17.3",
"sinon-chai": "^2.8.0",
"inject-loader": "^2.0.1",
"isparta-loader": "^2.0.0",
"phantomjs-prebuilt": "^2.1.3",
"chromedriver": "^2.21.2",
"cross-spawn": "^2.1.5",
"nightwatch": "^0.8.18",
"selenium-server": "2.53.0",
"ora": "^0.2.0",
"shelljs": "^0.6.0",
"url-loader": "^0.5.7",
"vue-hot-reload-api": "^1.2.0",
"vue-html-loader": "^1.0.0",
"vue-loader": "^8.3.0",
"vue-style-loader": "^1.0.0",
"webpack": "^1.12.2",
"webpack-dev-middleware": "^1.4.0",
"webpack-hot-middleware": "^2.6.0",
"webpack-merge": "^0.8.3"
}
}
webpack.base.conf.js
var path = require('path');
var config = require('../config');
var utils = require('./utils');
var projectRoot = path.resolve(__dirname, '../');
module.exports = {
entry: {
app: './src/main.js'
},
output: {
path: config.build.assetsRoot,
publicPath: config.build.assetsPublicPath,
filename: '[name].js'
},
resolve: {
extensions: ['', '.js', '.vue'],
fallback: [path.join(__dirname, '../node_modules')],
alias: {
'src': path.resolve(__dirname, '../src'),
'assets': path.resolve(__dirname, '../src/assets'),
'components': path.resolve(__dirname, '../src/components')
}
},
resolveLoader: {
fallback: [path.join(__dirname, '../node_modules')]
},
module: {
preLoaders: [
{
test: /\.vue$/,
loader: 'eslint',
include: projectRoot,
exclude: /node_modules/
},
{
test: /\.js$/,
loader: 'eslint',
include: projectRoot,
exclude: /node_modules/
}
],
loaders: [
{
test: /\.vue$/,
loader: 'vue'
},
{
test: /\.js$/,
loader: 'babel',
include: projectRoot,
exclude: /node_modules/
},
{
test: /\.json$/,
loader: 'json'
},
{
test: /\.html$/,
loader: 'vue-html'
},
{
test: /\.(png|jpe?g|gif|svg)(\?.*)?$/,
loader: 'url',
query: {
limit: 10000,
name: utils.assetsPath('img/[name].[hash:7].[ext]')
}
},
{
test: /\.(woff2?|eot|ttf|otf)(\?.*)?$/,
loader: 'url',
query: {
limit: 10000,
name: utils.assetsPath('fonts/[name].[hash:7].[ext]')
}
}
]
},
eslint: {
formatter: require('eslint-friendly-formatter')
},
vue: {
loaders: utils.cssLoaders()
//@todo add
// autoprefixer: {
// browsers: ['last 2 versions']
// }
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
我遇到过这个问题,vue-cli的issue里也有人提到了,这跟npm版本有关,新版npm在安装依赖的依赖的时候,降低了依赖的层级,怀疑vue-cli缺少了相应的更新。
按理说vue-html这个模块应该随着vue-loader一起安装,但一些版本的npm好像没装进来。
我的解决方法是手动安装vue-html
npm install vue-html --save-dev
后续vue-cli更新应该会解决这个问题。
npm install
我在npm上查了下,根本没有一个模块叫
vue-html
,你的webpack.config.js
里的内容是从哪找来的?重新vue init下了
发现问题了
使用npm@3.10.2进行
不会安装devdependencies的包
真诡异
缺少loader