webpack打包时Unknown option: direct.optional,该如何解决?
webpack打包时找不到vue文件,该如何解决?报了以下错误:
ERROR in ./src/user_entry.js
Module not found: Error: Cannot resolve 'file' or 'directory' ./user_info in D:
excenergy-javaheatingwebappsrc
@ ./src/user_entry.js 2:14-36
网友提示加了:
resolve: {
extensions: ['', '.js', '.vue']
},
又报了如下错误:
**ERROR in ./~/babel-loader!./~/vue-loader/lib/selector.js?type=script&index=0!./
rc/user_info.vue
Module build failed: Error: Cannot find module './lib/virtual-types'**
at Function.Module._resolveFilename (module.js:325:15)
at Function.Module._load (module.js:276:25)
at Module.require (module.js:353:17)
at require (internal/module.js:12:17)
at Object.<anonymous> (D:\excenergy-java\heating\webapp\node_modules\babel-
reset-stage-2node_modulesbabel-plugin-transform-class-propertiesnode_modules
babel-helper-function-namenode_modulesbabel-traverselibpathindex.js:13:21)
at Module._compile (module.js:409:26)
at Object.Module._extensions..js (module.js:416:10)
at Module.load (module.js:343:32)
at Function.Module._load (module.js:300:12)
at Module.require (module.js:353:17)
at require (internal/module.js:12:17)
at Object.<anonymous> (D:\excenergy-java\heating\webapp\node_modules\babel-
reset-stage-2node_modulesbabel-plugin-transform-class-propertiesnode_modules
babel-helper-function-namenode_modulesbabel-traverselibindex.js:10:13)
at Module._compile (module.js:409:26)
at Object.Module._extensions..js (module.js:416:10)
at Module.load (module.js:343:32)
at Function.Module._load (module.js:300:12)
at Module.require (module.js:353:17)
at require (internal/module.js:12:17)
at Object.<anonymous> (D:\excenergy-java\heating\webapp\node_modules\babel-
reset-stage-2node_modulesbabel-plugin-transform-class-propertiesnode_modules
babel-helper-function-namenode_modulesbabel-templatelibindex.js:69:22)
at Module._compile (module.js:409:26)
at Object.Module._extensions..js (module.js:416:10)
at Module.load (module.js:343:32)
at Function.Module._load (module.js:300:12)
at Module.require (module.js:353:17)
at require (internal/module.js:12:17)
at Object.<anonymous> (D:\excenergy-java\heating\webapp\node_modules\babel-
reset-stage-2node_modulesbabel-plugin-transform-class-propertiesnode_modules
babel-helper-function-namelibindex.js:63:46)
at Module._compile (module.js:409:26)
at Object.Module._extensions..js (module.js:416:10)
at Module.load (module.js:343:32)
at Function.Module._load (module.js:300:12)
@ ./src/user_info.vue 3:17-116
目录结构:
------------------------------------user_entery.js----------------------------------------------
var Vue=require('vue');
var user_info=require('./user_info');
new Vue({
el:'body',
components:{
app:user_info
}
});
------------------------------------user_info.vue---------------------------------------------
<style></style>
<template>
<appheader></appheader>
</template>
<script>
module.exports={
components:{
'appheader':require('./vue_header.vue');
}
}
</script>
------------------------------------webpack.config.js---------------------------------------------
var webpack=require('webpack');
var vue=require('vue-loader');
module.exports={
//页面入口文件配置
entry:{
userInfo:"./src/user_entry.js"
},
//输出配置
output:{
path:"dist",
filename:"[name].bundle.js"
},
resolve: {
extensions: ['', '.js', '.vue']
},
module:{
loaders:[
{test:/\.vue$/, loader:'vue'}
]
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
loader加上这个babel试试:
导入的时候漏写了
.vue
。或者在webpack配置里写上:你可以看看我写的demo,对照一下,看哪里有问题,https://github.com/MrZhang123...