-
Notifications
You must be signed in to change notification settings - Fork 309
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
Incorrect Error About Locating @angular/core in Yarn Workspaces Monorepo [Regression] #990
Comments
We introduced this to inform user that the util script needs to be explicitly run at root of the project to be able to run It's either can be a warning or throw error, that I wasn't sure so I made it to throw error. |
Error or warning isn't really the issue, so much as it's assuming the node_modules is adjacent to the package.json, and in yarn workspace setup it isn't. So it's mis-identifying the location that it's looking for. |
in the case of yarn workspace, the util script invokes |
It would probably be ok to just change it to warning and relax the language a bit. Something like "Warning: Could not locate @angular/core to run ngcc automatically. Please be sure to run ngcc prior to testing." Something that let's people know in case they do have a problematic setup, but doesn't error out on people who don't? Either that or improve the logic that tries to find the library |
I think changing to warning is the only way. We invoke |
I meant this logic, where it just defaults to cwd and then appends const nodeModuleDirPath = findNodeModulesDirectory(process.cwd());
const canRunNgcc =
!process.argv.find((arg) => IGNORE_ARGS.includes(arg)) && existsSync(join(nodeModuleDirPath, '@angular', 'core'));
function findNodeModulesDirectory(startPoint: string): string {
let current = startPoint;
while (dirname(current) !== current) {
const nodePath = join(current, 'node_modules');
if (existsSync(nodePath)) {
return nodePath;
}
current = dirname(current);
}
throw new Error(
`Cannot locate the 'node_modules' directory. Please make sure you are running jest from root level of your project`,
);
} |
Oh ye that one is assuming that this script is run from top of the project but doesn’t take into account of Yarn workspace. I’m curious if ngcc works with cwd instead of from root? Probably using |
Yeah, I don't believe it does. For example, if |
@ahnpnl thanks for the quick work on this. Really appreciate it. |
🐛 Bug Report
We have a monorepo with yarn workspaces, and Angular 12, Jest 27. This all worked with 9.0.4, but updating to 9.0.6 is incorrectly throwing an error about not being able to locate
@angular/core
(which is at the rootnode_modules
, not the localnode_modules
). I'm assuming it's related to this change: c35d3f2Rolling back to 9.0.4 fixes it.
Expected behavior
Should run in monorepo environment.
Error log:
envinfo
The text was updated successfully, but these errors were encountered: