TypeError: Object prototype may only be an Object or null: undefined

Hi:
I am getting error:
An unhandled exception occurred: Object prototype may only be an Object or null: undefined
when trying to build project in CI.
I found out the following dependencies while testing to build project:

  1. removed node_modules then npm install --no-package-lock --> ERROR
  2. existing node_modules from 1 then npm install --> WORKING
    3 removed node_modules then npm install --> WORKING
  3. existing node_modules from 3 then npm install --no-package-lock --> WORKING

Why the node modules directory is different when installing 1. and 3. from the same packge.json? As I know package-lock Is created by npm install based on package.json If it wouldnt be there, so… 1 test should install same dependencies without creating package-lock too.

What is the purpose of package-lock if npm install always override it. In CI there will be different dependencies installed afterall

Does your project have a package-lock.json? (No? Possibly affects step 1.)

What command are you running when you get the error in CI? (npm install?)

Sounds like you can reproduce locally, in which case would you please attach the log file?

(You have two step 3, so I am not sure which steps your followup question is comparing.)

Ok, let’s confine this to one example:

We have empty node_modules and no package-lock.json file.
So I do npm install (it will create package-lock) then ng build --prod

I attached angular-errors.log
angular-errors.log (1.5 KB)

These recent reports look similar, and solved by upgrading consistently to angular 8:

It solved my problem.
I changed to the same version:
"@angular/compiler": "~8.0.0", to "@angular/compiler": "~8.2.0", and
"@angular/cli": "^8.0.1", to "@angular/cli": "~8.2.0",
Thank You very match.

1 Like