Repository navigation
Angular never searches for zone.js in the correct path #27473
Description
Activity
Polyfills are resolved from the workspace root because they're referenced in the
angular.jsonfile. Typically, in an Angular CLI workspace, it's expected to have a singlenode_modulesdirectory at the top level of the workspace.Reacted by Motassem JalalReacted by Dibo- addedneeds: more infoReporter must clarify the issueReporter must clarify the issue
on Apr 16, 2024 Polyfills are resolved from the workspace root
that is what I need, but the actual behavior is that it searches in the monorepo's root rather than the workspace's root.
note that the Angular workspace is part of a monorepo.
Can you setup a minimal repro please?
You can read here why this is needed. A good way to make a minimal repro is to create a new app via
ng new repro-appand adding the minimum possible code to show the problem. Then you can push this repository to github and link it here.This might be related to your directory structure so its really important to get an accurate repro to diagnose this.
- addedneeds: repro stepsWe cannot reproduce the issue with the information givenWe cannot reproduce the issue with the information givenand removedneeds: more infoReporter must clarify the issueReporter must clarify the issue
on Apr 17, 2024 Can you setup a minimal repro please?
I updated the description with the minimal repro and steps to reproduction
Hello @its-dibo, thank you for your reproduction. It seems that this is an NX managed monorepo, so its operation differs slightly from an Angular CLI workspace due to the presence of multiple nested
projects.jsonand annx.jsonfile. In an NX monorepo, however the workspace root is where yournx.jsonis located, so the polyfills and othernode_modulesentries are resolved relative to that location.Reacted by Dibobut, as you know, pnpm creates s node_module folder for each package separately (hard links)
that's mean that polyfills can never be found, as they'll never be presents in the same level of nx.json- addedneeds: discussionOn the agenda for team meeting to determine next stepsOn the agenda for team meeting to determine next stepsand removedneeds: repro stepsWe cannot reproduce the issue with the information givenWe cannot reproduce the issue with the information given
on Apr 24, 2024 Had a brief discussion about this within the team and decided it probably makes sense to resolve polyfills from the project root. Projects should be relatively self-contained and have all the information to build themselves. They shouldn't need to rely on workspace-level information here, so it makes sense to be project -relative.
This is arguably a bug fix, but it is an observable change and probably safer to do in a major version. Let's include this in v19.
Reacted by hobeReacted by hobe- added and removedneeds: discussionOn the agenda for team meeting to determine next stepsOn the agenda for team meeting to determine next steps
on Jun 12, 2024 I had a similar issue, adding zone.js in the package.json did the trick for me.
With Angular 20 you have to include the zone.js in the package.json. Until version 19, the library was already included in Angular CLI (@angular/cli)"dependencies": { ... "@angular/compiler": "~20.1.7", ... "zone.js": "^0.15.1"Reacted by Dibo
Command
build
Is this a regression?
The previous version in which this bug was not present was
No response
Description
I have a monorepo, one of its workspaces is an Angular workspace. and I use pnpm to install the dependencies
each workspace has its own node_modules folder.
when I start building this app (the Angular workspace), it fails to find zone.js
it should find it inside node_modules of the Angular app
this debug info may be useful
as you can see it looks in:
but never looks in the correct path which is dibo/apps/mobarmegeen/mobarmegeen-ui/node_modules/zone.js
debug info
Minimal Reproduction
https://github.com/its-dibo/issue-zonejs
1- install via pnpm
pnpm installif pnpm is not installed, simply, run
npm I -g pnpm2- run the app
npm startnote: don't use any other package manager, as they hoist the packages of the app to the root of the monorepo.
.
Exception or Error
No response
Your Environment