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.

Does not package with ng-packagr

See original GitHub issue

Bug, feature request, or proposal:

When using ng-packagr, I receive a build error "ENOENT: no such file or directory, open ‘…/node_modules/@angular/packages/material…’

What is the expected behavior?

It packages properly with no build errors.

What is the current behavior?

It errors out and doesn’t build successfully but I can do ng build without issues.

What are the steps to reproduce?

  1. Start a new project using cli. ng new material-test
  2. Update dependencies to use @angular/material 2.0.0-beta.12 and all peer dependencies.
  3. Add ng-packagr to dev dependencies, all necessary files for ng-packagr (public_api & ng-package.json) and run npm install.
  4. Import any material module into main app module
  5. run ng-packagr -p ng-package.json.

OR

  1. Checkout https://github.com/nmrichards/material-issue-project
  2. run npm install
  3. run npm run packagr

What is the use-case or motivation for changing an existing behavior?

To be able to use ng-packagr with beta.12 in personal libraries.

Which versions of Angular, Material, OS, TypeScript, browsers are affected?

@angular 4.4.4 Material 2.0.0-beta.12 TypeScript 2.3.3

Is there anything else we should know?

I also receive messages during the ng-packagr process stating a number of items are imported but never used even if I only import one module from material library. See file below for said messages. In this particular test project, I’m only importing MatIconModule into the main app module. If I run ng-packagr on beta.11, I don’t receive the build error but still get the imported but not used messages and it successfully builds. I will also be submitting this to the ng-packagr project as I’m not sure if this an ng-packagr issue or material beta.12 issue but I only get the issue if I import any module from material beta.12. And also putting on Stack Overflow in case it’s just an issue that I’m causing due to something I’m doing wrong, in which case I apologize for submitting this issue.

EDIT: ng-packagr issue can be tracked here #172

screenshot 2017-10-10 07 48 10

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:4
  • Comments:25 (4 by maintainers)

github_iconTop GitHub Comments

23reactions
matt328commented, Oct 11, 2017

@willshowell adding material to lib.externals in ng-package.json:

{
  "lib": {
    "entryFile": ...,
    "externals": {
      "@angular/material": "ng.material"
    }
}

seems to have fixed my issue, my library is now building successfully with ng-packagr.

That is not to say there still isn’t some issue here with the esm5 packaging’s sourcemaps. I think someone consuming the esm5 package would likely face the same errors.

6reactions
matt328commented, Oct 10, 2017

I don’t think this should have been closed. Some clarification: we aren’t trying to use ng-packagr to build material itself. We are working on library projects that include material, and using ng-packagr to build those. The problem seems isolated to the esm5 packaging of material, which I am guessing not many people are using or else this issue would have much more traffic.

Is there a working example of a project successfully using beta.12’s esm5 packaging anywhere?

Edit: I have another project that is using a custom rollup configuration only building umd and fesm modules successfully with material beta.12, so I really think its an issue specific to the esm5 packaging.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Angular Library with ng-packagr - Medium
This format is a recommended way of building Angular libraries and distributing the packages. Libraries which are built using this format will ......
Read more >
Configuring ng-packagr in "package.json" is deprecated
What I'm asking for is why official documentation is not aligned with a deprecation message warning. According to the official docs they ...
Read more >
Creating libraries - Angular
Angular CLI uses a tool called ng-packagr to create packages from your compiled code that can be published to npm. See Building libraries...
Read more >
Building an Angular Library with multiple entry points | Articles
This is the package.json of your library (not to be confused with ... you should not export spec files. ng-packagr will throw an...
Read more >
Build an Angular Library With NgPackagr - Fireship
Angular packages are standardized by the Angular Package Format, ... Generate a library ng generate library awesome # Build it np run ...
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