brunocodutra/webapp-webpack-plugin

Error: Cannot find module 'core-js/modules/es6.array.sort'

THernandez03 opened this issue ยท 21 comments

Appear this error when using this plugin with Webpack4. I dont know how to debug plugins very well, so if you need something please tell me or show me how to start with ๐Ÿ˜„.

ร— ๏ฝขwdm๏ฝฃ: Error: Cannot find module 'core-js/modules/es6.array.sort'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:548:15)
    at Function.Module._load (internal/modules/cjs/loader.js:475:25)
    at Module.require (internal/modules/cjs/loader.js:598:17)
    at require (internal/modules/cjs/helpers.js:11:18)
    at Object.<anonymous> (C:\Projects\my-project\node_modules\favicons\dist\index.js:9:1)
    at Module._compile (internal/modules/cjs/loader.js:654:30)
    at Module._extensions..js (internal/modules/cjs/loader.js:665:10)
    at Object.require.extensions.(anonymous function) [as .js] (C:\Projects\my-project\node_modules\babel-register\lib\node.js:152:7)
    at Module.load (internal/modules/cjs/loader.js:566:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:506:12)

Could you verify whether adding "@babel/polyfill": "^7.0.0-beta.42" as a dependency fixes the issue?

Error: Cannot find module 'core-js/modules/es6.array.sort'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:548:15)
    at Function.Module._load (internal/modules/cjs/loader.js:475:25)
    at Module.require (internal/modules/cjs/loader.js:598:17)
    at require (C:\Projects\my-project\node_modules\v8-compile-cache\v8-compile-cache.js:159:20)
    at Object.<anonymous> (C:\Projects\my-project\node_modules\favicons\dist\index.js:9:1)
    at Module._compile (C:\Projects\my-project\node_modules\v8-compile-cache\v8-compile-cache.js:178:30)
    at Module._extensions..js (internal/modules/cjs/loader.js:665:10)
    at Object.require.extensions.(anonymous function) [as .js] (C:\Projects\my-project\node_modules\babel-register\lib\node.js:152:7)
    at Module.load (internal/modules/cjs/loader.js:566:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:506:12)
    at Function.Module._load (internal/modules/cjs/loader.js:498:3)
    at Module.require (internal/modules/cjs/loader.js:598:17)
    at require (C:\Projects\my-project\node_modules\v8-compile-cache\v8-compile-cache.js:159:20)
    at Object.<anonymous> (C:\Projects\my-project\node_modules\webapp-webpack-plugin\src\loader.js:2:18)
    at Module._compile (C:\Projects\my-project\node_modules\v8-compile-cache\v8-compile-cache.js:178:30)
    at Module._extensions..js (internal/modules/cjs/loader.js:665:10)
    at Object.require.extensions.(anonymous function) [as .js] (C:\Projects\my-project\node_modules\babel-register\lib\node.js:152:7)
    at Module.load (internal/modules/cjs/loader.js:566:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:506:12)
    at Function.Module._load (internal/modules/cjs/loader.js:498:3)
    at Module.require (internal/modules/cjs/loader.js:598:17)
    at require (C:\Projects\my-project\node_modules\v8-compile-cache\v8-compile-cache.js:159:20)
    at loadLoader (C:\Projects\my-project\node_modules\loader-runner\lib\loadLoader.js:13:17)
    at iteratePitchingLoaders (C:\Projects\my-project\node_modules\loader-runner\lib\LoaderRunner.js:169:2)
    at iteratePitchingLoaders (C:\Projects\my-project\node_modules\loader-runner\lib\LoaderRunner.js:165:10)
    at C:\Projects\my-project\node_modules\loader-runner\lib\LoaderRunner.js:185:6
    at context.callback (C:\Projects\my-project\node_modules\loader-runner\lib\LoaderRunner.js:111:13)
    at C:\Projects\my-project\node_modules\cache-loader\dist\index.js:133:7
    at ReadFileContext.callback (C:\Projects\my-project\node_modules\cache-loader\dist\index.js:200:7)
    at FSReqWrap.readFileAfterOpen [as oncomplete] (fs.js:434:13)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! new-project@0.0.1 build: `bash scripts/build.sh "app" "production"`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the new-project@0.0.1 build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\THernandez\AppData\Roaming\npm-cache\_logs\2018-04-12T20_03_50_958Z-debug.log```

Is this after adding @babel/polyfil as a dependency and running npm install?

I can't seem to be able to reproduce the issue locally on an empty project that depends only on webpack and webapp-webpack-plugin.

Could you paste the relevant parts of your package.json and webpack.config.js?

I will make a little project until it fails and show you what i'm using. thanks for the response

its solves if i install core-js dependency ๐Ÿค”

Could you check if v2.0.3 solves the issue?

No. It didn't solve the problem. Also viewing the changes you made to favicons repo I tried to install @babel/core, @babel/register but didn't work either

Damn it.

Can you share a repo that reproduces the issue?

I share you an invitation to see the project... its in the upgradeWebpack4 branch. To reproduce the error just install the modules and run npm run start app

I appreciate it, I'll have a look

After some tinkering I'm convinced the only reasonable solution is indeed to add core-js as a dependency. I can't really explain what's going on, but my only guess is that there is some weird interaction going on between babel@6 and babel@7.

Anyway, since adding core-js as a dependency does solve the problem, I'd say we can close this issue for now and reopen it in case more people report similar issues.

Please let me know what you think.

I think its ok... i thought something similar, but i was not sure at all.

Do you think it's a good idea to put an issue on @babel repo directly ?

I don't think there's much we can do about it while projects that depend on different major versions of babel coexist, I guess that's the flip side of the paced js/node community, where there is such a thing as packages that evolve almost too fast.

yarn add babel-preset-env --dev helped me solving this (using nuxt-edge)

its solves if i install core-js dependency!!! yay!!!, im using nuxt 2.4

I'm able to get this to work as long as I install core-js@2.6.5. The newer 3.0 version does not solve the problem for me.

ian commented

@drewda's solution works. Problem seems to be that core-js renamed es6 directory to es gatsby broke as a result.

yarn add core-js
ๅฆ‚ๆžœ่ฟ˜ไธ่กŒ
ๅˆ ้™ค node_modules,็„ถๅŽไฝฟ็”จ yarn ๅฎ‰่ฃ…๏ผŒไธ่ฆไฝฟ็”จ cnpm ๅฎ‰่ฃ…๏ผ›

in similar core-js/modules/xxx/yyy error, my solution is to delete node_modules folder and reinstall.

@ian same goes for Gridsome.