F
F
Fear12018-03-17 15:53:01
webpack
Fear1, 2018-03-17 15:53:01

How to fix an error when building bundle.js in Webpack?

The error is the following:
5aad0f49157a9629708939.png

package.json
{
  "name": "vueify",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1",
    "build": "webpack",
    "start": "webpack --watch"
  },
  "devDependencies": {
    "babel-core": "^6.18.2",
    "babel-loader": "^6.2.7",
    "babel-plugin-transform-runtime": "^6.15.0",
    "babel-preset-es2015": "^6.18.0",
    "babel-preset-stage-0": "^6.24.1",
    "css-loader": "^0.25.0",
    "vue": "*",
    "vue-cli": "*",
    "vue-html-loader": "^1.2.3",
    "vue-loader": "*",
    "vue-style-loader": "^1.0.0",
    "vue-template-compiler": "*",
    "webpack": "*",
    "webpack-cli": "*"
  },
  "keywords": [],
  "author": "",
  "license": "ISC"
}

webpack.config.js
'use strict'
const path = require('path');

module.exports = {
  entry: './main.js',
  output: {
    path: path.resolve(__dirname, 'dist'),
    filename: 'bundle.js'
  },
  module: {
  	rules: [
  		{
            test: /\.vue$/,
            loader: 'vue-loader'
        }
  	]
  }
};

hello.vue
<template>
  <h1>{{ msg }}</h1>
</template>

<script>
  module.exports = {
    data: function() {
      return {
        msg: 'Hello Webpack!'
      }
    }
  }
</script>

<style>
  h1 {
    color: green;
  }
</style>


What am I doing wrong and how to fix the error?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vitaly Stolyarov, 2018-03-18
@Ni55aN

Try vue-loaderspecifying the version explicitly instead of *

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question