2

I am developing a no standalone angular app with the command --no-standalone but when I'm trying to add @angular/material, it throws the following error:

Cannot find module '..\node_modules\@schematics\angular\private\components.js'
5
  • I was able to reproduce this running npx @angular/cli@18 new ng18-app --no-standalone --no-ssr --style=scss, navigating to the newly created folder and running ng add @angular/material. Strangely, the schematics tried to add Angular Material v17 which seems wrong. There is a related open GitHub issue: github.com/angular/components/issues/30090 Commented Nov 27, 2024 at 8:08
  • 1
    it was a problem with angular 18 and you did an unnecessary editing to my question. The problem got fixed when i deleted both node module and package-lock.json file and cleared cache. It solved my issue. Commented Nov 27, 2024 at 10:12
  • 1
    My edit of your question was not unnecessary, it greatly improves the readability. If commands / errors / package names are all just regular text, it's really hard to distinguish between those and the text explaining the question. If you found a workaround, you can add an answer to your own question. Commented Nov 27, 2024 at 10:18
  • 1
    i appreciate that but unnecessary was for, at the time someone comes to help it was already resolved by myself. Commented Nov 27, 2024 at 10:39
  • 1
    Maybe it will help future readers, so hopefully it was not unnecessary :) Commented Nov 27, 2024 at 11:13

2 Answers 2

0

Deleting node_modules and package-lock from the application, then clearing cache before installation of modules fixed my problem.

Sign up to request clarification or add additional context in comments.

Comments

-1

This is an issue with the Angular CLI's code to determine the compatible version of the package to add. The code changes to fix the issue have been merged, however for now only into the v19 branch.

As a workaround, you can specify the major version of Angular Material like the following:

ng add @angular/material@18

1 Comment

Thanks @JSON Derulo, the workaround that worked for me was commented further down github.com/angular/angular-cli/issues/…

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.