0

tested on node 13.10.1

I'm installing some Angular Libraries+schematics (written by me) via ng add command. The libraries are added to the package.json but not to the package-lock.json. When I try to serve my project, I got an error message for the libraries peerDependecies not satisfied.

  1. I run npm i <missingpackages...>
  2. I run ng serve

Then I got a new error, the Angular libraries I installed before are now vanished. Only their scope folder is left (@my-corp)

  1. Then I re-run npm i <libraries...>,
  2. ng-serve

And everything works fine (the libraries has been added to the package-lock.json too). Can anyone explains me this weird behaviour?

Nemus
  • 1,322
  • 2
  • 23
  • 47

1 Answers1

0

I found a solution.

The core of the issue is the lack of updates in package-lock.json after the ng add <library>command was run.

If you're the angular-library developer, to solve this its sufficient to execute inside the rule factory function this code:

export function ngAdd(options: ISchema): Rule {
  exec('npm i --package-lock-only'); // <- this code
  return (host: Tree, context: SchematicContext) => {...};
}

If you're just a consumer, run this from the cli

npm i --package-lock-only

Hope this helps

Nemus
  • 1,322
  • 2
  • 23
  • 47