首页 > Cannot find module .vue

Cannot find module .vue

参照vuex的counter demo。代码敲完了,但是运行一直是 Cannot find module App.vue

components和vuex目录下的代码和vuex文档里的代码一样 http://vuex.vuejs.org/zh-cn/t...

App.vue里的代码

<template>
    <div>
        <Display></Display>
        <Increment></Increment>
    </div>
</template>
<style>
</style>
<script>
    import Display from './components/Display.vue'
    import Increment from './components/Increment.vue'
    import store from './vuex/store'

    export default {
        components: {
            Display,
            Increment
        },
        store
    }
</script>

webpack.config.js内容:

module.exports = {
  entry: './main.js',
  output: {
    path: process.cwd(),
    filename: 'build.js'
  },
  module: {
    loaders: [
      {
        test: /\.js$/,
        loader: 'babel',
        exclude: /node_modules/
      },
      {
        test: /\.vue$/,
        loader: 'vue'
      }
    ]
  },
  devtool: '#source-map'
}

新手,实在是找不到办法,才来提问的,感谢大神指条明路


webpack-config.js里添加如下代码:

babel: {
    presets: ['es2015'],
    plugins: ['transform-runtime']
}

错误提示Cannot find module App.vue应该是webpack没有把App.vue作为模块的解析的原因。缺少vue-loader

但是。。。。你确定安装过依赖包了没?看你的工程里没有node_modules目录的。

如果没有

npm install

【热门文章】
【热门文章】