Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
alexander-heimbuch opened this issue Apr 26, 2018 · 6 comments

Comments

@alexander-heimbuch
Copy link

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()
   ]
}
@vue-bot
Copy link

vue-bot commented Apr 26, 2018

Hello, your issue has been closed because it does not conform to our issue requirements. In order to ensure every issue provides the necessary information for us to investigate, we require the use of the Issue Helper when creating new issues. Thank you!

@vue-bot vue-bot closed this as completed Apr 26, 2018
@sgehrman
Copy link

same problem. Need answers, not authoritarian bots.

@yyx990803
Copy link
Member

@sgehrman or maybe you can try to respect the issue requirements and follow the instructions?

@sgehrman
Copy link

I think the solution is to use "loader" instead of "use" for single loader strings

I had:
use: 'vue-loader'
use: 'eslint-loader'

but should have had
loader: 'vue-loader'
loader: 'eslint-loader'

use is for arrays, loader is for a single string it seems based on my quick googling.

Was that so hard? Did it really require two closed issues, codepen repros, and telling me to respect the rules?? Sorry, I didn't have helicopter parents. I'm not brainwashed to blindly follow authority and ridiculous rules that make no sense.

@yyx990803
Copy link
Member

@sgehrman please don't ever come back.

@yyx990803
Copy link
Member

yyx990803 commented Apr 27, 2018

@sgehrman It's not about authority, it's about respecting the rules set by the maintainers who spent time working on something and giving it to you for free, who have to deal with hundreds of issues every week, and had to set down these rules to be able to stay efficient and sane. If you can't deal with it, go use whatever other software that solves your problems. I don't need users like you.

@vuejs vuejs locked and limited conversation to collaborators Apr 27, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants