Skip to content
This repository has been archived by the owner on Sep 9, 2021. It is now read-only.

Cannot read property 'createChildCompiler' of undefined #177

Closed
sohailalam2 opened this issue Dec 27, 2018 · 16 comments
Closed

Cannot read property 'createChildCompiler' of undefined #177

sohailalam2 opened this issue Dec 27, 2018 · 16 comments

Comments

@sohailalam2
Copy link

Original Issue at: vuejs/vue-cli#3192 and webpack-contrib/thread-loader#55

Here is a minimum reproducible test repo https://github.com/sohailalam2/mrt-vue-comlinkjs-worker-loader

Vue Cli Version

3.2.1

Environment info

Environment Info:

  System:
    OS: Windows 10
    CPU: (8) x64 Intel(R) Core(TM) i7-8650U CPU @ 1.90GHz
  Binaries:
    Node: Not Found
    Yarn: Not Found
    npm: 6.5.0 - C:\Program Files\nodejs\npm.CMD
  Browsers:
    Edge: 42.17134.1.0
  npmPackages:
    @vue/babel-preset-app:  3.2.0
    @vue/cli-overlay:  3.2.0
    @vue/cli-plugin-babel: ^3.2.0 => 3.2.0
    @vue/cli-plugin-e2e-cypress: ^3.2.0 => 3.2.0
    @vue/cli-plugin-eslint: ^3.2.0 => 3.2.1
    @vue/cli-plugin-pwa: ^3.2.0 => 3.2.0
    @vue/cli-plugin-unit-jest: ^3.2.0 => 3.2.0
    @vue/cli-service: ^3.2.0 => 3.2.0
    @vue/cli-shared-utils:  3.2.0
    @vue/component-compiler-utils:  2.3.1
    @vue/eslint-config-airbnb: ^4.0.0 => 4.0.0
    @vue/preload-webpack-plugin:  1.1.0
    @vue/test-utils: ^1.0.0-beta.20 => 1.0.0-beta.27
    @vue/web-component-wrapper:  1.2.0
    babel-helper-vue-jsx-merge-props:  2.0.3
    babel-plugin-transform-vue-jsx:  4.0.1
    eslint-plugin-vue: ^5.0.0-0 => 5.0.0
    jest-serializer-vue:  2.0.2
    vue: ^2.5.17 => 2.5.21
    vue-eslint-parser:  2.0.3
    vue-hot-reload-api:  2.3.1
    vue-jest:  3.0.2
    vue-loader:  15.4.2
    vue-router: ^3.0.1 => 3.0.2
    vue-style-loader:  4.1.2
    vue-template-compiler: ^2.5.17 => 2.5.21
    vue-template-es2015-compiler:  1.6.0
    vuex: ^3.0.1 => 3.0.1
  npmGlobalPackages:
    @vue/cli: Not Found

Steps to reproduce

Step 1: Create vue.config.js with the following

module.exports = {
  parallel: true,
  chainWebpack: (config) => {
    config.module.rule('worker')
      .test(/\.worker\.js$/i)
      .use('worker-loader')
      .loader('worker-loader');
  },
};

Step 2: npm run serve

What is expected?

Should successfully build the project

What is actually happening?

ERROR Failed to compile with 1 errors 4:46:14 PM

error in ./src/workers/sample.worker.js

Module build failed (from ./node_modules/thread-loader/dist/cjs.js):
Thread Loader (Worker 0)
Cannot read property 'createChildCompiler' of undefined

at Object.pitch (xxxxx\node_modules\worker-loader\dist\index.js:83:39)

@ ./node_modules/cache-loader/dist/cjs.js??ref--12-0!./node_modules/thread-loader/dist/cjs.js!./node_modules/babel-loader/lib!./node_modules/cache-loader/dist/cjs.js??ref--0-0!./node_modules/vue-loader/
lib??vue-loader-options!./src/components/HelloWorld.vue?vue&type=script&lang=js& 45:0-51 71:33-45
@ ./src/components/HelloWorld.vue?vue&type=script&lang=js&
@ ./src/components/HelloWorld.vue
@ ./node_modules/cache-loader/dist/cjs.js??ref--12-0!./node_modules/thread-loader/dist/cjs.js!./node_modules/babel-loader/lib!./node_modules/cache-loader/dist/cjs.js??ref--0-0!./node_modules/vue-loader/
lib??vue-loader-options!./src/views/Home.vue?vue&type=script&lang=js&
@ ./src/views/Home.vue?vue&type=script&lang=js&
@ ./src/views/Home.vue
@ ./src/router.js
@ ./src/main.js
@ multi ./src/main.js

ERROR Build failed with errors.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! app@0.1.0 build: vue-cli-service build --modern
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the app@0.1.0 build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.


Turning off parallel flag in vue.config.js successfully builds the project

module.exports = {
  parallel: false,
  chainWebpack: (config) => {
    config.module.rule('worker')
      .test(/\.worker\.js$/i)
      .use('worker-loader')
      .loader('worker-loader');
  },
};
@alexander-akait
Copy link
Member

alexander-akait commented Dec 27, 2018

Please don't spam issue in may repos, also your reproducible test repo is not look as minimum.

Simple example = fast fix.

@sohailalam2
Copy link
Author

Apologies... don't mean to spam... I just don't know what's the root cause of this - Vue Cli or Worker Loader or Thread Loader?

About the reproducible test, it's quite straightforward because I have used Vue Cli to generate the code and made only some small changes. If you want more explanation, I can document the details but I don't know how else to reproduce this issue.

@alexander-akait
Copy link
Member

alexander-akait commented Dec 27, 2018

@sohailalam2 don't worry just put link on reproducible test repo here, in my todo list

@stoplion
Copy link

Having same issue with worker loader

@illbredmiscreant
Copy link

Any status change in regards to this issue? Also experiencing this problem.

@alexander-akait
Copy link
Member

PR welcome

@chopfitzroy
Copy link

chopfitzroy commented Mar 18, 2019

Same issue, not sure what is the cause, if I nuke the node_modules directory and reinstall it does work, but eventually breaks again and I have to reinstall.

UPDATE

parallel: false, does not appear to fix the issue, still having to nuke node_modules and re-install on each occurrence.

UPDATE 2

Seems to be some sort of caching issues, because it happens whenever I modify the worker file.

@raczosala
Copy link

perhaps is related with webpack-contrib/thread-loader#27

@wanecek
Copy link

wanecek commented Apr 12, 2019

I'm also running into the issue described above. I created a slightly smaller case fr reproduction, maybe this can help in isolating the issue @evilebottnawi? :)

To summarize, the build-task fails with the error-message above. Removing the node_modules folder does not fix the issue for me.

@PowerfulPony
Copy link

PowerfulPony commented Aug 2, 2019

The same error that appeared after using worker-loader appears only with npm run build. That is, for npm run serve everything works as usual, using vue-cli.

Module build failed (from ./node_modules/thread-loader/dist/cjs.js):
Thread Loader (Worker 0)
Cannot read property 'createChildCompiler' of undefined
    at PoolWorker.fromErrorObj (...\node_modules\thread-loader\dist\WorkerPool:258:12)
    at Object.pitch (...\node_modules\worker-loader\dist\index.js:83:39)

It helps off parallel parallel: false,

@Yanfei-Qiao
Copy link

Also run into this problem, parallel: false helps, but I want to know if there is an elegent solution

@sysebert
Copy link

@CrashyBang's fix worked for me (having to delete node_modules and re-running npm install).

This allowed the npm run build to finish (like others in this thread have stated, npm run serve works fine)

ryanlee2014 added a commit to ryanlee2014/CUP-Online-Judge-Frontend that referenced this issue Mar 22, 2020
@zoswing
Copy link

zoswing commented May 8, 2020

it seems that you should add "options"
e.g.

config.module
      .rule('worker')
      .test(/\.worker\.js$/)
      .use('worker-loader')
      .loader('worker-loader')
      .options({ name: '[name].[hash].js' })
      .end()

by the way "parallel" should be 'false'

@a-froghyar
Copy link

I'm facing the same issue described above, only deleting node_modules and installing everything again solves the problem temporarily (until changes in the worker). Has anyone found out a solution?

@alexander-akait
Copy link
Member

Problem in thread-loader side, we will fix it in the near future, sorry for delay, as workaround you can disable thread-loader for worker files using exclude: /\.worker\.js$/

@brianhelba
Copy link

brianhelba commented Jun 15, 2020

@evilebottnawi Until this is actually fixed, is there an open issue tracking this bug? The thread-loader issue was closed in favor of this one.

Thanks for the update and workaround.

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