How to update core-js to core-js@3 dependency?

React NativeNpm Install

React Native Problem Overview


While I was trying to install and setup react native, the precaution observed about the core-js version as update your core-js@... to core-js@3 But don't know how to update my core-js.

$ sudo react-native init AwesomeProject121
Password:
This will walk you through creating a new React Native project in /Users/amarnr1989/AwesomeProject121
Using yarn v1.13.0
Installing react-native...
yarn add v1.13.0
info No lockfile found.
[1/4] πŸ”  Resolving packages...
warning react-native > create-react-class > fbjs > core-js@1.2.7: core-js@<2.6.5 is no longer maintained. Please, upgrade to core-js@3 or at least to actual version of core-js@2.
[2/4] 🚚  Fetching packages...
[----------------------------------------------------------------------------------------------------------------------------------------------------------] 0/601internal/modules/cjs/loader.js:584
    throw err;
    ^

Error: Cannot find module '/Users/amarnr1989/AwesomeProject121/node_modules/react-native/package.json'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:582:15)
    at Function.Module._load (internal/modules/cjs/loader.js:508:25)
    at Module.require (internal/modules/cjs/loader.js:637:17)
    at require (internal/modules/cjs/helpers.js:22:18)
    at checkNodeVersion (/usr/local/lib/node_modules/react-native-cli/index.js:306:21)
    at run (/usr/local/lib/node_modules/react-native-cli/index.js:300:3)
    at createProject (/usr/local/lib/node_modules/react-native-cli/index.js:249:3)
    at init (/usr/local/lib/node_modules/react-native-cli/index.js:200:5)
    at Object.<anonymous> (/usr/local/lib/node_modules/react-native-cli/index.js:153:7)
    at Module._compile (internal/modules/cjs/loader.js:701:30)

Please Suggest

React Native Solutions


Solution 1 - React Native

You update core-js with the following command:

npm install --save core-js@^3

If you read the React Docs you will find that the command is derived from when you need to upgrade React itself.

Solution 2 - React Native

For npm

 npm install --save core-js@^3

for yarn

yarn add core-js@^3

Solution 3 - React Native

For ng9 upgraders:

npm i -g core-js@^3

..then:

npm cache clean -f

..followed by:

npm i

Solution 4 - React Native

How about reinstalling the node module? Go to the root directory of the project and remove the current node modules and install again.

These are the commands : rm -rf node_modules npm install

OR

npm uninstall -g react-native-cli and

npm install -g react-native-cli

Solution 5 - React Native

With this

npm install --save core-js@^3

you now get the error

"core-js@<3 is no longer maintained and not recommended for usage due to the number of
issues. Please, upgrade your dependencies to the actual version of core-js@3"

so you might want to instead try

npm install --save core-js@3

if you're reading this post June 9 2020.

Solution 6 - React Native

Install

npm i core-js

Modular standard library for JavaScript. Includes polyfills for ECMAScript up to 2019: promises, symbols, collections, iterators, typed arrays, many other features, ECMAScript proposals, some cross-platform WHATWG / W3C features and proposals like URL. You can load only required features or use it without global namespace pollution.

Read: https://www.npmjs.com/package/core-js

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionAmarView Question on Stackoverflow
Solution 1 - React NativeChiaroView Answer on Stackoverflow
Solution 2 - React NativeParveen ChauhanView Answer on Stackoverflow
Solution 3 - React NativeJason MullingsView Answer on Stackoverflow
Solution 4 - React Nativehong developerView Answer on Stackoverflow
Solution 5 - React Nativeuser9895412View Answer on Stackoverflow
Solution 6 - React NativeDinesh MView Answer on Stackoverflow