Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

1.8K
Views
error de publicación de la biblioteca angular 9 "Intentando publicar un paquete que ha sido compilado por Ivy"

Migré mi proyecto angular angular 8.xx a angular 9.xx y cuando intento publicar mi biblioteca, falla con el siguiente error

npm ¡ERROR! @candiman/website@9.0.0 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

¿Hay algo cambiado en el angular 9

over 4 years ago · Santiago Trujillo
8 answers
Answer question

0

ACTUALIZAR ANGULAR 12

usar la opción --configuration production mientras construía la biblioteca solucionó mi problema

 ng build --configuration production

Respuesta original:

usar la opción --prod mientras construía la biblioteca solucionó mi problema

 ng build yourLibraryName --prod
over 4 years ago · Santiago Trujillo Report

0

Según los documentos oficiales de Angular https://angular.io/guide/ivy#opting-out-of-ivy-in-version-9

es mejor optar por no participar en el compilador Ivy para usar el antiguo View Engine al crear y publicar su biblioteca agregando esta línea:

enableIvy: false

a angularCompilerOptions en el archivo tsconfig.json en la raíz de su biblioteca, como se puede ver a continuación;

ingrese la descripción de la imagen aquí

Lo probé después de actualizar mi biblioteca Angular a la versión 9 de Angular y este pequeño cambio funcionó de maravilla.

over 4 years ago · Santiago Trujillo Report

0

En mi caso, ninguna de las soluciones anteriores funcionó. Sin embargo, noté que en el package.json de mi biblioteca en la carpeta dist hay una secuencia de comandos recién agregada (probablemente agregada debido a esto ):

"scripts": { "prepublishOnly": "node --eval \"console.error('ERROR: Trying to publish a package that has been compiled by NGCC. This is not allowed.\\nPlease delete and rebuild the package, without compiling with NGCC, before attempting to publish.\\nNote that NGCC may have been run by importing this package into another project that is being built with Ivy enabled.\\n')\" && exit 1" }
"scripts": { "prepublishOnly": "node --eval \"console.error('ERROR: Trying to publish a package that has been compiled by NGCC. This is not allowed.\\nPlease delete and rebuild the package, without compiling with NGCC, before attempting to publish.\\nNote that NGCC may have been run by importing this package into another project that is being built with Ivy enabled.\\n')\" && exit 1" }

Entonces, aquí elimine/reemplace el script prepublishOnly o publique usando npm publish --ignore-scripts

over 4 years ago · Santiago Trujillo Report

0

agregando

"compilationMode": "parcial"

para

"opciones del compilador angular": {

}

Resolvió mi problema

over 4 years ago · Santiago Trujillo Report

0

En su archivo angular.json , tiene un objeto de build en su árbol de biblioteca. Dentro de build , tiene un objeto de configurations , que contiene un objeto de production y probablemente también un objeto de development .

Dentro del objeto de build , defina una nueva propiedad llamada defaultConfiguration y establezca el valor: production que coincida con el nombre de la propiedad de production dentro del objeto de configurations .

Su archivo angular.json debería verse así:

 "architect": { build": { "builder": "@angular-devkit/build-ng-packagr:build", "options": { "tsConfig": "projects/ngx-custom-tooltip/tsconfig.lib.json", "project": "projects/ngx-custom-tooltip/ng-package.json" }, "configurations": { "production": { "tsConfig": "projects/ngx-custom-tooltip/tsconfig.lib.prod.json" }, "development": { "tsConfig": "projects/ngx-custom-tooltip/tsconfig.lib.json" } }, "defaultConfiguration": "production" }, ... }

Su tsconfig.lib.prod.json debe contener este objeto:

 "angularCompilerOptions": { "enableIvy": false }

Finalmente, puedes ejecutar ng build your-library-name

over 4 years ago · Santiago Trujillo Report

0

Mientras construía mis bibliotecas con ng build --prod y enableIvy = false en tsconfig.lib.json , estaba obteniendo el mismo script "prepublishOnly" agregado a mi package.json de espacio de trabajo.json que tenía Melchia .

La razón por la que parece estar relacionada con el uso de un repositorio privado a través de publishConfig/registry en el package.json de cada biblioteca, como se indica en https://github.com/angular/angular/issues/37973#issuecomment-656136865

Al crear bibliotecas angulares para publicación, use ng build --prod , enableIvy = false en el archivo tsconfig.json de la biblioteca y, si trabaja con un repositorio privado, npm publish --ignore-scripts

over 4 years ago · Santiago Trujillo Report

0

Además de agregar el indicador --prod , si está ejecutando una versión muy antigua, también necesitará la siguiente actualización de angular.json :

 "myproject": { ... "architect": { "build": { ... "configurations": { "production": { "tsConfig": "projects/mypath/tsconfig.lib.prod.json" } } },

siendo el contenido de ese archivo:

 { "extends": "./tsconfig.lib.json", "angularCompilerOptions": { "enableIvy": false } }

Puede verificar si tiene una versión tan antigua si todavía tiene las siguientes líneas en angular.json :

 "production": { "project": "projects/tsmean/spinner/ng-package.prod.json" }
over 4 years ago · Santiago Trujillo Report

0

Arreglo para el problema de estilo de componente faltante de Angular 12+

En Angular 12, mientras usa:

 ng build --configuration production

de hecho, resolvió el problema original para mí, también introdujo uno nuevo: los estilos de mi componente de biblioteca faltaban por completo.

He resuelto este otro problema reemplazando:

 "angularCompilerOptions": { "enableIvy": false }

con:

 "angularCompilerOptions": { "compilationMode": "partial" }

en projects/my-library/tsconfig.lib.prod.json

Fuente: https://angular.io/guide/creating-libraries#building-libraries-with-ivy

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!