babel: ModuleNotFoundError: Module not found: Error: Can't resolve 'core-js/library/fn/object/define-property'
Bug Report
Babel Configuration (.babelrc, package.json, cli command)
{
presets: [
[
'@babel/preset-env',
{
loose: true,
modules: false,
targets: { browsers: ['last 2 versions', 'Firefox ESR', '> 1%', 'ie >= 10', 'iOS >= 8', 'Android >= 4'] }
}
]
],
plugins: [
'@babel/plugin-syntax-dynamic-import',
['@babel/plugin-proposal-decorators', { legacy: true }],
['@babel/plugin-transform-runtime', { useESModules: true }],
['@babel/plugin-proposal-class-properties', { loose: true }],
['@babel/plugin-proposal-object-rest-spread', { useBuiltIns: true }],
['import', { style: true, libraryName: 'antd', libraryDirectory: 'es', style: true }]
],
env: {
development: {
presets: [['@babel/preset-react', { development: true, useBuiltIns: true }]]
},
production: {
presets: [['@babel/preset-react', { useBuiltIns: true }]],
plugins: [['transform-react-remove-prop-types', { removeImport: true }]]
}
}
};
Environment
- Babel version(s): 7.4.0
- Node/npm version: 11
- OS: Windows 10
Babel version(s): 7.3.4 is ok!
ModuleNotFoundError: Module not found: Error: Can't resolve 'core-js/library/fn/object/set-prototype-of' in 'D:\WORKSPACE\node_modules\babel-runtime\core-js\object'
at factory.create (D:\WORKSPACE\node_modules\webpack\lib\Compilation.js:823:10)
at factory (D:\WORKSPACE\node_modules\webpack\lib\NormalModuleFactory.js:397:22)
at resolver (D:\WORKSPACE\node_modules\webpack\lib\NormalModuleFactory.js:130:21)
at asyncLib.parallel (D:\WORKSPACE\node_modules\webpack\lib\NormalModuleFactory.js:224:22)
at D:\WORKSPACE\node_modules\neo-async\async.js:2825:7
at D:\WORKSPACE\node_modules\neo-async\async.js:6886:13
at normalResolver.resolve (D:\WORKSPACE\node_modules\webpack\lib\NormalModuleFactory.js:214:25)
at doResolve (D:\WORKSPACE\node_modules\enhanced-resolve\lib\Resolver.js:184:12)
at hook.callAsync (D:\WORKSPACE\node_modules\enhanced-resolve\lib\Resolver.js:238:5)
at _fn0 (eval at create (D:\WORKSPACE\node_modules\tapable\lib\HookCodeFactory.js:32:10), <anonymous>:15:1)
at resolver.doResolve (D:\WORKSPACE\node_modules\enhanced-resolve\lib\UnsafeCachePlugin.js:37:5)
at hook.callAsync (D:\WORKSPACE\node_modules\enhanced-resolve\lib\Resolver.js:238:5)
at _fn0 (eval at create (D:\WORKSPACE\node_modules\tapable\lib\HookCodeFactory.js:32:10), <anonymous>:15:1)
at hook.callAsync (D:\WORKSPACE\node_modules\enhanced-resolve\lib\Resolver.js:238:5)
at _fn0 (eval at create (D:\WORKSPACE\node_modules\tapable\lib\HookCodeFactory.js:32:10), <anonymous>:12:1)
at resolver.doResolve (D:\WORKSPACE\node_modules\enhanced-resolve\lib\DescriptionFilePlugin.js:42:38)
at hook.callAsync (D:\WORKSPACE\node_modules\enhanced-resolve\lib\Resolver.js:238:5)
at _fn42 (eval at create (D:\WORKSPACE\node_modules\tapable\lib\HookCodeFactory.js:32:10), <anonymous>:390:1)
at resolver.doResolve (D:\WORKSPACE\node_modules\enhanced-resolve\lib\ModuleKindPlugin.js:23:37)
at hook.callAsync (D:\WORKSPACE\node_modules\enhanced-resolve\lib\Resolver.js:238:5)
at _fn0 (eval at create (D:\WORKSPACE\node_modules\tapable\lib\HookCodeFactory.js:32:10), <anonymous>:15:1)
at hook.callAsync (D:\WORKSPACE\node_modules\enhanced-resolve\lib\Resolver.js:238:5)
at _fn1 (eval at create (D:\WORKSPACE\node_modules\tapable\lib\HookCodeFactory.js:32:10), <anonymous>:24:1)
at hook.callAsync (D:\WORKSPACE\node_modules\enhanced-resolve\lib\Resolver.js:238:5)
at _fn0 (eval at create (D:\WORKSPACE\node_modules\tapable\lib\HookCodeFactory.js:32:10), <anonymous>:15:1)
at resolver.doResolve (D:\WORKSPACE\node_modules\enhanced-resolve\lib\UnsafeCachePlugin.js:37:5)
at hook.callAsync (D:\WORKSPACE\node_modules\enhanced-resolve\lib\Resolver.js:238:5)
at _fn0 (eval at create (D:\WORKSPACE\node_modules\tapable\lib\HookCodeFactory.js:32:10), <anonymous>:15:1)
at hook.callAsync (D:\WORKSPACE\node_modules\enhanced-resolve\lib\Resolver.js:238:5)
at _fn0 (eval at create (D:\WORKSPACE\node_modules\tapable\lib\HookCodeFactory.js:32:10), <anonymous>:12:1)
at resolver.doResolve (D:\WORKSPACE\node_modules\enhanced-resolve\lib\DescriptionFilePlugin.js:42:38)
at hook.callAsync (D:\WORKSPACE\node_modules\enhanced-resolve\lib\Resolver.js:238:5)
at _fn43 (eval at create (D:\WORKSPACE\node_modules\tapable\lib\HookCodeFactory.js:32:10), <anonymous>:402:1)
at hook.callAsync (D:\WORKSPACE\node_modules\enhanced-resolve\lib\Resolver.js:238:5)
at _fn0 (eval at create (D:\WORKSPACE\node_modules\tapable\lib\HookCodeFactory.js:32:10), <anonymous>:12:1)
at resolver.doResolve (D:\WORKSPACE\node_modules\enhanced-resolve\lib\DescriptionFilePlugin.js:42:38)
resolve 'core-js/library/fn/object/set-prototype-of' in 'D:\WORKSPACE\node_modules\babel-runtime\core-js\object'
Parsed request is a module
using description file: D:\WORKSPACE\node_modules\babel-runtime\package.json (relative path: ./core-js/object)
Field 'browser' doesn't contain a valid alias configuration
resolve as module
looking for modules in D:\WORKSPACE\Assets\src
using description file: D:\WORKSPACE\package.json (relative path: ./Assets/src)
Field 'browser' doesn't contain a valid alias configuration
using description file: D:\WORKSPACE\package.json (relative path: ./Assets/src/core-js/library/fn/object/set-prototype-of)
no extension
Field 'browser' doesn't contain a valid alias configuration
D:\WORKSPACE\Assets\src\core-js\library\fn\object\set-prototype-of doesn't exist
.js
Field 'browser' doesn't contain a valid alias configuration
D:\WORKSPACE\Assets\src\core-js\library\fn\object\set-prototype-of.js doesn't exist
.jsx
Field 'browser' doesn't contain a valid alias configuration
D:\WORKSPACE\Assets\src\core-js\library\fn\object\set-prototype-of.jsx doesn't exist
as directory
D:\WORKSPACE\Assets\src\core-js\library\fn\object\set-prototype-of doesn't exist
looking for modules in D:\WORKSPACE\node_modules
using description file: D:\WORKSPACE\package.json (relative path: ./node_modules)
Field 'browser' doesn't contain a valid alias configuration
using description file: D:\WORKSPACE\node_modules\core-js\package.json (relative path: ./library/fn/object/set-prototype-of)
no extension
Field 'browser' doesn't contain a valid alias configuration
D:\WORKSPACE\node_modules\core-js\library\fn\object\set-prototype-of doesn't exist
.js
Field 'browser' doesn't contain a valid alias configuration
D:\WORKSPACE\node_modules\core-js\library\fn\object\set-prototype-of.js doesn't exist
.jsx
Field 'browser' doesn't contain a valid alias configuration
D:\WORKSPACE\node_modules\core-js\library\fn\object\set-prototype-of.jsx doesn't exist
as directory
D:\WORKSPACE\node_modules\core-js\library\fn\object\set-prototype-of doesn't exist
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 2
- Comments: 31 (13 by maintainers)
Commits related to this issue
- [package] v2.0.2 Workaround that fix core-js https://github.com/babel/babel/issues/9734 — committed to gulp-flow/gulp-flow-webpack by Nicolab 5 years ago
- :heavy_plus_sign: added core-js@2 dependency see https://github.com/babel/babel/issues/9734\#issue-423654875 for more details regarding the original issue, in project error was : Cannot find module 'c... — committed to krzepah/mutasync-server by deleted user 5 years ago
- :heavy_plus_sign: added core-js@2 dependency [issue](https://github.com/babel/babel/issues/9734\#issue-423654875 - in project error was : Cannot find module 'core-js/modules/es6.object.define-property... — committed to krzepah/mutasync-server by deleted user 5 years ago
- :heavy_plus_sign: added core-js@2 dependency https://github.com/babel/babel/issues/9734\#issue-423654875 - in project error was : Cannot find module 'core-js/modules/es6.object.define-property' from ... — committed to krzepah/mutasync-server by deleted user 5 years ago
- Chore: npm audit (#39) * Chore: npm audit fix --force * Chore: add core-js@2 dependency https://github.com/babel/babel/issues/9734\#issue-423654875 - in project error was : Cannot find module 'c... — committed to aichbauer/express-rest-api-boilerplate by deleted user 5 years ago
npm i --save core-js@2
might workaround the problem.I think that this might be a problem with npm.
babel-runtime
(which is probably required by one of your dependencies), explitily relies oncore-js@^2.4.0
(https://unpkg.com/babel-runtime@6.26.0/package.json), and the file that is throwing the error should exist: https://unpkg.com/core-js@2.4.0/library/fn/object/set-prototype-of.js.Do
node_modules/babel-runtime/node_modules/core-js/library/fn/object/set-prototype-of.js
ornode_modules/core-js/library/fn/object/set-prototype-of.js
esist in your project?What is the “version” field of the
package.json
s ofnode_modules/babel-runtime/node_modules/core-js
andnode_modules/core-js
?@nuintun I think that because Babel internally depended on core-js@2, so it was in you node modules and npm hoisted it to the top-level node_modules folder.
You can read an explanation of what is happening (why Babel internally upgrading a non-exposed dependency broke many packages) at https://github.com/parcel-bundler/parcel/issues/2819#issuecomment-475008861, keeping in mind that it was probably “fault” of a dependency of your project.
@ZOXEXIVO I have no idea about how “fetch as Google” works. If you have a lockfile, you can check which corejs version was installed and re-install exactly that one.
Thanks, I will check it later today 👍
See tests and results - seems it’s buggy in Edge.