Skip to content

TypeError: Cannot assign to read only property '0' of string 'vue-loader' #1256

Closed
@alexander-heimbuch

Description

@alexander-heimbuch

After the update to Webpack 4 (4.6) the webpack build fails with the following error right on start of the process:

TypeError: Cannot assign to read only property '0' of string 'vue-loader'
    at VueLoaderPlugin.apply (/path/to/my/project/node_modules/vue-loader/lib/plugin.js:97:42)
    at webpack (/path/to/my/project/node_modules/webpack/lib/webpack.js:37:12)
    at processOptions (/path/to/my/project/node_modules/webpack-cli/bin/webpack.js:436:16)
    at yargs.parse (/path/to/my/project/node_modules/webpack-cli/bin/webpack.js:512:3)
    at Object.parse (/path/to/my/project/node_modules/yargs/yargs.js:552:18)
    at /path/to/my/project/node_modules/webpack-cli/bin/webpack.js:217:8
    at Object.<anonymous> (/path/to/my/project/node_modules/webpack-cli/bin/webpack.js:514:3)
    at Module._compile (module.js:643:30)
    at Object.Module._extensions..js (module.js:654:10)
    at Module.load (module.js:556:32)
    at tryModuleLoad (module.js:499:12)
    at Function.Module._load (module.js:491:3)
    at Module.require (module.js:587:17)
    at require (internal/module.js:11:18)
    at Object.<anonymous> (/path/to/my/project/node_modules/webpack/bin/webpack.js:80:2)
    at Module._compile (module.js:643:30)
    at Object.Module._extensions..js (module.js:654:10)
    at Module.load (module.js:556:32)
    at tryModuleLoad (module.js:499:12)
    at Function.Module._load (module.js:491:3)
    at Function.Module.runMain (module.js:684:10)
    at startup (bootstrap_node.js:187:16)
    at bootstrap_node.js:608:3

If I remove the VueLoaderPlugin from my plugins the build runs till the vue files needs to be parsed.

Corresponding webpack config:

{
  mode: 'production',

  entry: {
    embed: path.resolve(sourceDir, 'embed', 'embed.js'),
    window: path.resolve(sourceDir, 'embed', 'window.js'),
    share: path.resolve(sourceDir, 'embed', 'share.js'),
    vendor: path.resolve(sourceDir, 'vendor.js')
  },

  output: {
    path: distDir,
    filename: '[name].js',
    publicPath: ''
  },

  resolve: {
    extensions: ['*', '.js', '.vue', '.json'],
    alias: {
      'vue$': 'vue/dist/vue.common.js',
      store: path.resolve(sourceDir, 'store'),
      utils: path.resolve(sourceDir, 'utils'),
      shared: path.resolve(sourceDir, 'components', 'shared'),
      icons: path.resolve(sourceDir, 'components', 'icons'),
      lang: path.resolve(sourceDir, 'lang'),
      core: path.resolve(sourceDir, 'core'),
      styles: path.resolve(sourceDir, 'styles')
    }
  },

  module: {
    rules: [{
      test: /\.vue$/,
      use: 'vue-loader'
    }, {
      test: /\.js?$/,
      loader: 'babel-loader'
    }, {
        test: /\.scss$/,
        use: [
          MiniCssExtractPlugin.loader,
          'css-loader',
          'scss-loader'
        ]
    }, {
      test: /\.(png|jpg|gif|jpeg|svg)$/,
      loader: 'file-loader',
      options: {
        name: '[name].[ext]?[hash]'
      }
    }, {
      test: /\.(eot|svg|ttf|woff|woff2)$/,
      loader: 'file-loader',
      options: {
        name: 'fonts/[name].[ext]?[hash]'
      }
    }]
  },

  plugins: [
      new VueLoaderPlugin(),
      new MiniCssExtractPlugin({
        filename: 'style.css'
      }),

      new webpack.DefinePlugin({
        BASE: JSON.stringify(get(process.env, 'BASE', '.'))
      }),

      new UglifyJsPlugin()
   ]
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions