Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't use a local copy of primeng locally. #15460

Closed
axos88 opened this issue May 6, 2024 · 2 comments
Closed

Can't use a local copy of primeng locally. #15460

axos88 opened this issue May 6, 2024 · 2 comments
Labels
Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible

Comments

@axos88
Copy link

axos88 commented May 6, 2024

Describe the bug

There is a module resolution error when using a local copy of the primeng repository. I suspect it has something to do with the tsconfig.json include path configured for the primeng library, I tried copying over the declaration correcting the path to no avail.

Environment

Angular 17 project using a local copy of the primeng source code

Reproducer

No response

Angular version

17

PrimeNG version

master

Build / Runtime

Angular CLI App

Language

TypeScript

Node version (for AoT issues node --version)

18

Browser(s)

n/a

Steps to reproduce the behavior

  1. [email protected]:primefaces/primeng.git
  2. npm run build:package
  3. cd my-project
  4. npm i ../primeng/dist
  5. ng build

Expected behavior

Compiles.

Actual behaviour:
/src/main.ts - Error: Module build failed (from ./node_modules/@ngtools/webpack/src/ivy/index.js):
Error: Cannot resolve type entity i2.ButtonModule to symbol

./src/polyfills.ts - Error: Module build failed (from ./node_modules/@ngtools/webpack/src/ivy/index.js):
Error: Cannot resolve type entity i2.ButtonModule to symbol

Error: ../../primeng/dist/api/contextmenuservice.d.ts:1:26 - error TS2307: Cannot find module 'primeng/ts-helpers' or its corresponding type declarations.

1 import { Nullable } from 'primeng/ts-helpers';
~~~~~~~~~~~~~~~~~~~~

Error: ../../primeng/dist/button/button.d.ts:2:31 - error TS2307: Cannot find module 'primeng/api' or its corresponding type declarations.

2 import { PrimeTemplate } from 'primeng/api';
~~~~~~~~~~~~~

Error: ../../primeng/dist/button/button.d.ts:5:21 - error TS2307: Cannot find module 'primeng/ripple' or its corresponding type declarations.

5 import * as i2 from "primeng/ripple";
~~~~~~~~~~~~~~~~

and so on.

@axos88 axos88 added the Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible label May 6, 2024
@axos88
Copy link
Author

axos88 commented May 7, 2024

Correction:

Adding the following to the main project's tsconfig.json seems to allow compilation to succeed, however it throws an exception on app initialization:

    "paths": {
      "primeng/*": ["../node_modules/primeng/*/public_api"]
    },
main.ts:27 ERROR Error: NG0203: inject() must be called from an injection context such as a constructor, a factory function, a field initializer, or a function used with `runInInjectionContext`. Find more at https://angular.io/errors/NG0203
    at injectInjectorOnly (core.mjs:1093:15)
    at Module.ɵɵinject (core.mjs:1106:60)
    at Object.RouterModule_Factory [as useFactory] (router.mjs:424:103)
    at Object.factory (core.mjs:3322:38)
    at core.mjs:3219:47
    at runInInjectorProfilerContext (core.mjs:866:9)
    at R3Injector.hydrate (core.mjs:3218:21)
    at R3Injector.get (core.mjs:3082:33)
    at injectInjectorOnly (core.mjs:1100:40)
    at ɵɵinject (core.mjs:1106:60)
handleError @ core.mjs:6531
(anonymous) @ core.mjs:31269
invoke @ zone.js:365
run @ zone.js:111
runOutsideAngular @ core.mjs:18451
(anonymous) @ core.mjs:31269
invoke @ zone.js:365
onInvoke @ core.mjs:18555
invoke @ zone.js:364
run @ zone.js:111
(anonymous) @ zone.js:2438
invokeTask @ zone.js:400
(anonymous) @ core.mjs:18229
onInvokeTask @ core.mjs:18229
invokeTask @ zone.js:399
onInvokeTask @ core.mjs:18542
invokeTask @ zone.js:399
runTask @ zone.js:158
drainMicroTaskQueue @ zone.js:579
Zone - Promise.then (async)
onScheduleTask @ core.mjs:18223
scheduleTask @ zone.js:379
onScheduleTask @ zone.js:267
scheduleTask @ zone.js:379
scheduleTask @ zone.js:201
scheduleMicroTask @ zone.js:221
scheduleResolveOrReject @ zone.js:2428
resolvePromise @ zone.js:2362
(anonymous) @ zone.js:2445
invokeTask @ zone.js:400
(anonymous) @ core.mjs:18229
onInvokeTask @ core.mjs:18229
invokeTask @ zone.js:399
onInvokeTask @ core.mjs:18542
invokeTask @ zone.js:399
runTask @ zone.js:158
drainMicroTaskQueue @ zone.js:579
Zone - Promise.then (async)
onScheduleTask @ core.mjs:18223
scheduleTask @ zone.js:379
onScheduleTask @ zone.js:267
scheduleTask @ zone.js:379
scheduleTask @ zone.js:201
scheduleMicroTask @ zone.js:221
scheduleResolveOrReject @ zone.js:2428
then @ zone.js:2633
(anonymous) @ core.mjs:35094
_callAndReportToErrorHandler @ core.mjs:31266
(anonymous) @ core.mjs:35091
invoke @ zone.js:365
onInvoke @ core.mjs:18555
invoke @ zone.js:364
run @ zone.js:111
run @ core.mjs:18406
internalCreateApplication @ core.mjs:35068
bootstrapApplication @ platform-browser.mjs:1027
4429 @ main.ts:27
__webpack_require__ @ bootstrap:19
__webpack_exec__ @ primeng-utils.ts:3
(anonymous) @ primeng-utils.ts:3
__webpack_require__.O @ chunk loaded:23
(anonymous) @ primeng-utils.ts:3
webpackJsonpCallback @ jsonp chunk loading:71
(anonymous) @ main.js:2
Show 57 more frames
Show less
11:02:48.099 main.ts:66 Error: NG0203: inject() must be called from an injection context such as a constructor, a factory function, a field initializer, or a function used with `runInInjectionContext`. Find more at https://angular.io/errors/NG0203
    at injectInjectorOnly (core.mjs:1093:15)
    at Module.ɵɵinject (core.mjs:1106:60)
    at Object.RouterModule_Factory [as useFactory] (router.mjs:424:103)
    at Object.factory (core.mjs:3322:38)
    at core.mjs:3219:47
    at runInInjectorProfilerContext (core.mjs:866:9)
    at R3Injector.hydrate (core.mjs:3218:21)
    at R3Injector.get (core.mjs:3082:33)
    at injectInjectorOnly (core.mjs:1100:40)
    at ɵɵinject (core.mjs:1106:60)

Note that I am NOT using inject calls outside the allowed places, and the same code works with primeng version 17.16.0 downloaded from the official npm source.

@axos88
Copy link
Author

axos88 commented May 7, 2024

Effin preserveSymlinks: true solved the issue.

@axos88 axos88 closed this as completed May 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible
Projects
None yet
Development

No branches or pull requests

1 participant