70

I'm getting below error while creating a new Angular application -

npm WARN deprecated core-js@2.6.11: 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.

I tried the solution given in below link but it did not work for me- Error: Please, upgrade your dependencies to the actual version of core-js@3

When I check version of Angular using 'ng --version' command, I see <error> as version for below listed packages -

@angular-devkit/architect    
@angular-devkit/core         
@angular-devkit/schematics   
@schematics/angular          
@schematics/update   

Could you please suggest what went wrong and what needs to be done to fix this?

P.S. - The same functionality was working fine a day before. And the already created projects are running fine locally.

Surjeet Bhadauriya
  • 6,755
  • 3
  • 34
  • 52
jaihind
  • 1,090
  • 1
  • 8
  • 9
  • 3
    Run command "npm outdated" inside your project directory. And see the difference between the Current And Wanted version of packages. And try to upgrade them to match wanted version. – Surjeet Bhadauriya Dec 20 '19 at 06:50
  • 1
    with 'npm outdated' command inside project directory I got the list of packages to update/install. I did install/update these packages inside the project directory and then I could run the application successfully. However, when I try to create a new project with 'ng new test-project', I get the same error. How should I resolve this issue permanently? – jaihind Dec 20 '19 at 07:13
  • https://github.com/npm/npm/issues/19672#issuecomment-397323622 please refer to this thread – Devansh sadhotra May 01 '20 at 05:48
  • 1
    @SurjeetBhadauriya How come "core-js" doesn't show up when I run the command "npm outdated"? Output from the command listed some other modules. I updated them, but how would I ensure that core-js has been updated to resolve the original problem? – Lazor Dec 08 '20 at 01:00

8 Answers8

33

Indeed the issue was with cache. npm clean-install worked.

jaihind
  • 1,090
  • 1
  • 8
  • 9
21

It's a npm cache problem. Go to the path:

  • Windows: %AppData%/npm-cache
  • Linux/OSX: ~/.npm

and delete its content. Then open your console in administrator mode and execute the npm install command again

Shanerk
  • 5,175
  • 2
  • 40
  • 36
nehemie konan
  • 236
  • 1
  • 5
  • 1
    This doesn't really work. Besides of the deprecated messages I also got an Error message, "Unexpected end of JSON input while parsing near '....1" – Jamo Jun 08 '20 at 23:46
21

Try:

npm cache clean --force
npm install -g @angular/cli@latest
anubhab
  • 730
  • 1
  • 7
  • 11
  • 1
    npm cache clean --force command throws an error : module.js:550 throw err; ^ Error: Cannot find module '../lib/utils/unsupported.js' – TechCare99 May 30 '20 at 14:35
17

You should update the version of core-js to version above 3. npm install --save core-js@^3

You may also update the outdated packages using npm update [-g] [<pkg>...]

nXn
  • 904
  • 6
  • 13
  • I tried installing version 3 of core-js but it does not work. I get below error - npm WARN saveError ENOENT: no such file or directory, open 'D:\TypeScript_WorkSpace\package.json' npm WARN enoent ENOENT: no such file or directory, open 'D:\TypeScript_WorkSpace\package.json' npm WARN TypeScript_WorkSpace No description npm WARN TypeScript_WorkSpace No repository field. npm WARN TypeScript_WorkSpace No README data npm WARN TypeScript_WorkSpace No license field. If I run this command from inside the project directory, it works but when it comes to creating new project, it doesn't. – jaihind Dec 20 '19 at 09:03
  • your second suggestion is a great start, but what I would add to your answer is **how do we detect which packages we using core-js@ to begin with**. Once we know how to do that, then your 2nd line makes more sense to do as a final step. – klewis Jan 23 '20 at 13:43
  • 9
    @klewis You can identify which packages rely on core-js by running the command `npm ls core-js`. What's more, you can specifically identify v2 references by running `npm ls core-js@2`. – Paul Rowe Apr 01 '20 at 16:18
4

I observed this warning message within a Vaadin project with Vaadin 14.1.3 after switching from dependency com.vaadin.vaadin to com.vaadin.vaadin-core. The warning was gone after these steps:

  1. delete package-lock.json
  2. execute mvn clean
  3. execute mvn update
S. Doe
  • 685
  • 1
  • 6
  • 25
  • where package-lock.json file is located? – Sébastien REMY Mar 16 '20 at 09:25
  • In my case the package-lock.json is placed in the root of the Vaadin project. It's the same directory where package.json is placed and the same where (in case you use a Maven project) your pom.xml is placed. – S. Doe Mar 18 '20 at 07:24
2

So the issue is of version of the packages you have in your project.

Run command npm outdated inside your project directory. And see the difference between the Current And Wanted version of packages.

And then upgrade all package to match wanted version.

Surjeet Bhadauriya
  • 6,755
  • 3
  • 34
  • 52
  • 5
    The solutions given do work for a specific project but the issue is that the same problem occurs when I try to create any other new application. – jaihind Dec 20 '19 at 09:04
0

For reactjs project, update your react-scripts. Just run yarn add react-scripts@latest or npm install react-scripts@latest.

This was what helped me after trying all the above commands

0

In my case it turned out to be an issue with the node version. I downgraded from v16.0.0 to v14.17.1 and it was fixed.

Kirill
  • 21
  • 3