27

I'm almost finished developing my application with ionic and angular. Unfortunately, I'm totally stuck. I can't build my application (on android) anymore.

Here's the error:

ionic cordova build android
cordova.cmd platform add android --save
Using cordova-fetch for cordova-android@^8.0.0
Failed to fetch platform cordova-android@^8.0.0
Probably this is either a connection problem, or platform spec is incorrect.
Check your connection and platform name/version/URL.
Error: npm: Command failed with exit code 1 Error output:
npm ERR! code EINVALIDPACKAGENAME
npm ERR! Invalid package name "__ngcc_entry_points__.json": name cannot start with an underscore

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\Jules\AppData\Roaming\npm-cache\_logs\2020-06-09T17_09_27_363Z-debug.log
[ERROR] An error occurred while running subprocess cordova.

This problem had already happened to me on another project. To fix it I just had to search in the file explorer and rename __ngcc_entry_points__.json without the underscore of the beginning. Even if some time later it would come back, I just had to rename it to.

Unfortunately, __ngcc_entry_points__.json is totally untraceable everywhere in my project. I'm completely blocked.

Sampath
  • 63,341
  • 64
  • 307
  • 441
VeeN
  • 479
  • 1
  • 5
  • 14
  • 1
    May it be related to https://stackoverflow.com/questions/33816824/getting-npm-err-code-epeerinvalid-on-npm-packages-global-install Also you can try to remove node_modules folder and run 'npm install' again – Ostn Jun 09 '20 at 21:13

7 Answers7

59

Solution to this problem is:

rm -rf node_modules

npm install 
M--
  • 25,431
  • 8
  • 61
  • 93
Jonathan Duarte
  • 848
  • 1
  • 8
  • 10
  • 13
    This fixes 99% of problems related with npm. – user276648 Oct 30 '20 at 05:15
  • 6
    Also I needed to delete the `package-lock.json` as suggested in https://stackoverflow.com/a/63889891/626639 – Seega Jan 15 '21 at 11:34
  • 1
    It would be helpful if you explained what the command 'rm -rf node_modules' is actually telling npm to do. – jake Oct 04 '21 at 15:37
  • 3
    @jake rm isn't an npm command, it just deletes the node_modules folder. There's a nice summary of what the flags mean here: https://askubuntu.com/a/670655/938513 – DrRelling Oct 13 '21 at 14:36
  • 1
    The answer is "Delete node_modules folder and then run npm install". rm -rf is a command for Linux OS. – rick Dec 08 '21 at 14:05
  • Awful solution. he should just delete __ngcc_entry_points__ entry from package.lock.json – roma2341 Apr 30 '22 at 12:37
17

I have often experienced seeing this error message while working on Angular projects. And that prevents adding any dependencies due to the conflicts in the package-lock.json file. Whereas removing the node modules folder and reinstalling them gets rid of this, it's not always feasible to do that as for bigger projects, it can consume a lot of time. The solution that works for me is

  1. Deleting package-lock.json file
  2. Deleting ngcc_entry_points.json file from the node_modules folder
  3. Running npm install (It just recreates the package-lock.json file) And just like that conflicts get resolved! Hope it helps save time for someone.
Arindam Dawn
  • 1,769
  • 2
  • 18
  • 35
10

I had this problem and it was caused due to __ngcc_entry_points__ element in package-lock.json file (can be located in the root directory, next to package.json).

Removing the __ngcc_entry_points__ element from package-lock.json, deleting node_modules and running npm install again fixed the problem

Aharon Ohayon
  • 1,171
  • 1
  • 17
  • 20
8

For me, the solution was to remove any space from the "name" in package.json, for example

{
  "name": "My App",
  "version": "0.0.1",
  ...

becomes

{
  "name": "My_App",
  "version": "0.0.1",
  ...
user276648
  • 6,018
  • 6
  • 60
  • 86
Yalin
  • 345
  • 2
  • 9
2

Check if the name of your app in package.json is valid.

https://docs.npmjs.com/files/package.json

user276648
  • 6,018
  • 6
  • 60
  • 86
1

Ionic 6+ / Capaciotr 3+

Error:

Invalid package name "ngcc_entry_points.json": name cannot start with an underscore

My issue here was on the package.json file:

I have put version like so: "version": "1.5.0-build:2",

But it didn't work. So changed it to: "version": "1.5.0", and no issue now.

Sampath
  • 63,341
  • 64
  • 307
  • 441
0

I´m new to Angular, and I got this same error when installing OAuth2 complement. It was just the wrong folder (I know, very beginner mistake), if you are trying to run npm command check you are at your common directory.