question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ng-package.json is ignored if in same directory as package.json

See original GitHub issue

Type of Issue

[x] Bug Report
[ ] Feature Request

Description

It is pretty common to create an ng-package.json file and put it alongside package.json, and use that as the input to ng-packagr. It is expected that package.json would be ignored, since it is just for development. With version 2.3 and 2.4 this scenario is broken. The entire contents of ng-pacakge.json will be ignore and the contents of package.json used instead.

How To Reproduce

  1. Create an Angular app with a normal package.json
  2. Create a file called ng-package.json alongside package.json, e.g.
{
  "$schema": "./node_modules/ng-packagr/package.schema.json",
  "name": "myapp",
  "version": "0.0.1",
  "ngPackage": {
    "lib": {
      "entryFile": "public_api.ts"
    }
  }
}
  1. Create a public_api.ts file, again in that same directory
  2. Run ng-packagr -p ng-package.json

I see this error:

BUILD ERROR
error TS6053: File '/Users/pbeber/myapp/src/public_api.ts' not found.

This error is happening because it is ignoring the contents of ng-package.json and using package.json instead. Package.json has no ngPackage node so it is using the default value for ngPackage.lib.entryFile which is “src/public_api.ts”.

I made a repo that reproduces the problem:

git clone https://github.com/philipbeber/packagr-example.git
cd packagr-example
npm install
npm run packagr

Expected Behaviour

I expect it to work and to use the config parameters in ng-pacakge.json, since that’s the file I’m telling it to use.

Version Information

$ node_modules/.bin/ng-packagr --version
ng-packagr:            2.4.2
@angular/compiler:     5.2.10
@angular/compiler-cli: 5.2.9
rollup:                0.55.5
tsickle:               0.27.2
typescript:            2.5.3

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:6

github_iconTop GitHub Comments

1reaction
philipbebercommented, Apr 27, 2018

Same thing then. The ngPackage is only needed in package.json, not ng-package.json.

0reactions
github-actions[bot]commented, Jun 19, 2020

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

This action has been performed automatically by a bot.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Include assets when building library using ng-packagr
Adding my actual ng-package.json for benefit of others. I wanted to copy the assets folder and all its contents to the library and...
Read more >
Create a Library for an NPM package - DEV Community ‍ ‍
ng-package.json. Notice the error on the missing ng-packagr npm folder? ... We saw the typical fsevents errors and ignored them.
Read more >
package.json npm can't find a package.json file in your current ...
json dependencies to the latest versions, ignoring specified versions. maintains existing semantic versioning policies, i.e. "express": "^4.0.0" to "express": " ...
Read more >
ng-packagr - npm
Create one package.json per npm package, run ng-packagr for each! ... the library's package.json in the same folder next to ng-package.json ...
Read more >
Workspace and project file structure - Angular
A workspace contains the files for one or more projects. ... package-lock.json, Provides version information for all packages installed into node_modules by ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found