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.

angular 10 library publish error “Trying to publish a package that has been compiled by Ivy”

See original GitHub issue

🐞 bug report

Affected Package

The issue is caused by package @angular-devkit/build-angular:browser

Is this a regression?

No. In version 9 it is expected behavior. But suppose it should not happen in angular V10

Description

I have created project and generate library with angular 10. But I can’t set enableIvy to “true” build and publish my package. It throw error:

my-lib@0.0.1 prepublishOnly . node --eval “console.error(‘ERROR: Trying to publish a package that has been compiled by Ivy. This is not allowed.\nPlease delete and rebuild the package, without compiling with Ivy, before attempting to publish.\n’)” && exit 1

ERROR: Trying to publish a package that has been compiled by Ivy. This is not allowed. Please delete and rebuild the package, without compiling with Ivy, before attempting to publish.

npm ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR! my-lib@0.0.1 prepublishOnly: node --eval "console.error('ERROR: Trying to publish a package that has been compiled by Ivy. This is not allowed.\nPlease delete and rebuild the package, without compiling with Ivy, before attempting to publish.\n')" && exit 1 npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the my-lib@0.0.1 prepublishOnly script. npm ERR! This is probably not a problem with npm. There is likely additional logging output above. npm WARN Local package.json exists, but node_modules missing, did you mean to install?

npm ERR! A complete log of this run can be found in: npm ERR! /home/aa/.npm/_logs/2020-07-08T13_03_35_422Z-debug.log

🔬 Minimal Reproduction

repository with issue: https://github.com/Sikatrih/ng-cli-lib-ivy-issue

🌍 Your Environment


**Angular Version:**
Angular CLI: 10.0.1
Node: 12.16.2
OS: linux x64

Angular: 10.0.2
... animations, common, compiler, compiler-cli, core, forms
... platform-browser, platform-browser-dynamic, router
Ivy Workspace: Yes

Package                            Version
------------------------------------------------------------
@angular-devkit/architect          0.1000.1
@angular-devkit/build-angular      0.1000.1
@angular-devkit/build-ng-packagr   0.1000.1
@angular-devkit/build-optimizer    0.1000.1
@angular-devkit/build-webpack      0.1000.1
@angular-devkit/core               10.0.1
@angular-devkit/schematics         10.0.1
@angular/cli                       10.0.1
@ngtools/webpack                   10.0.1
@schematics/angular                10.0.1
@schematics/update                 0.1000.1
ng-packagr                         10.0.0
rxjs                               6.5.5
typescript                         3.9.6
webpack                            4.43.0

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:9 (5 by maintainers)

github_iconTop GitHub Comments

4reactions
petebacondarwincommented, Jul 20, 2020

The reason is actually forward compatibility. If we allow ivy compiled libraries to be published right now, then we lock ourselves into a very specific use of the ivy instruction set and data structures. This would affect us from being able to make implementation changes that would fix bugs, improvement performance, reduce code size etc. By keeping the ivy internals private we can be more agile going forward.

The current way to achieve this is by requiring ViewEngine compiled code (since this leaves the decorator information in place), which ngcc is able to convert to ivy code at library installation/ application build time. Going forward we are looking into a partially compiled library format that will have the best of both worlds: not requiring a lengthy ngcc build step, but also not exposing the internals of the ivy runtime.

1reaction
petebacondarwincommented, Jul 9, 2020

In that case the simple workaround is to remove the prepublishOnly property from the library’s package.json before publishing.

Read more comments on GitHub >

github_iconTop Results From Across the Web

angular 9 library publish error "Trying to ... - Stack Overflow
@candiman/website@9.0.0 prepublishOnly: node --eval "console.error('ERROR: Trying to publish a package that has been compiled by Ivy.
Read more >
Deploying Angular 9 ivy packages - Medium
"prepublishOnly": "node --eval \"console.error('ERROR: Trying to publish a package that has been compiled by Ivy. This is not allowed.
Read more >
Publish Angular 12 Library Built with Ivy to Npm - ADocLib
angular 9 library publish error Trying to publish a package that has been compiled by Ivy Code Utility I've tried it after updating...
Read more >
The Angular linker (goodbye ngcc!) - Ninja Squad
Angular 11.1+ allows to ship partially compiled libraries to NPM. ... getting "Trying to publish a package that has been compiled by Ivy....
Read more >
ngx-bootstrap-datetime-popup - UNPKG
35, "prepublishOnly": "node --eval \"console.error('ERROR: Trying to publish a package that has been compiled by Ivy. This is not allowed.
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