nativescript-schematics icon indicating copy to clipboard operation
nativescript-schematics copied to clipboard

Cannot find module '@schematics/angular/utility/parse-name'

Open kdmakwana43 opened this issue 4 years ago • 37 comments

I installed @nativescript/[email protected] for my Nativescript project and tried to generate component using command its show me following error.

An unhandled exception occurred: Cannot find module '@schematics/angular/utility/parse-name'

See "/private/var/folders/g0/3gly57n500zb1xvl7rffy_100000gn/T/ng-Mxey0g/angular-errors.log" for further details.

here is errors.log

[error] Error: Cannot find module '@schematics/angular/utility/parse-name' at Function.Module._resolveFilename (internal/modules/cjs/loader.js:636:15) at Function.Module._load (internal/modules/cjs/loader.js:562:25) at Module.require (internal/modules/cjs/loader.js:690:17) at require (internal/modules/cjs/helpers.js:25:18) at Object. (/Users/apple/Codenatial/nativescript/demo/node_modules/@nativescript/schematics/src/generate/component/index.js:6:22) at Module._compile (internal/modules/cjs/loader.js:776:30) at Object.Module._extensions..js (internal/modules/cjs/loader.js:787:10) at Module.load (internal/modules/cjs/loader.js:653:32) at tryModuleLoad (internal/modules/cjs/loader.js:593:12) at Function.Module._load (internal/modules/cjs/loader.js:585:3)

when I downgrade @nativescript/[email protected] to @nativescript/[email protected] its working fine.

kdmakwana43 avatar Aug 17 '19 08:08 kdmakwana43

Hi @kdmakwana43,

Does your project have a dependency on @angular/cli? The @nativescript/schematics package tries to require a utility function from @schematics/angular. @schematics/angular is a dependency of @angular/cli. To fix the error, install the Angular CLI in your project:

npm install -D @angular/cli

sis0k0 avatar Aug 26 '19 10:08 sis0k0

This worked for me. npm i --save-dev @nativescript/schematics

ronolivarph avatar Sep 03 '19 02:09 ronolivarph

Hi @kdmakwana43,

Does your project have a dependency on @angular/cli? The @nativescript/schematics package tries to require a utility function from @schematics/angular. @schematics/angular is a dependency of @angular/cli. To fix the error, install the Angular CLI in your project:

npm install -D @angular/cli

That works for me. Love you! :)

luenmuvel avatar Sep 06 '19 05:09 luenmuvel

Hi @kdmakwana43, Does your project have a dependency on @angular/cli? The @nativescript/schematics package tries to require a utility function from @schematics/angular. @schematics/angular is a dependency of @angular/cli. To fix the error, install the Angular CLI in your project:

npm install -D @angular/cli

That works for me. Love you! :)

I just login to say it work and thank you

likhi1 avatar Sep 07 '19 10:09 likhi1

This worked for me. npm i --save-dev @nativescript/schematics

Thanks! It works for me!

edrockfsd avatar Sep 13 '19 20:09 edrockfsd

npm install -D @angular/cli npm i --save-dev @nativescript/schematic

These Commands Collectively helped me

WaseemAhmadZ avatar Nov 01 '19 11:11 WaseemAhmadZ

The following fixed the issue for me :

npm i --save-dev @nativescript/schematics

arunabhdas avatar Nov 05 '19 14:11 arunabhdas

Nothing helped me.

First, I had an error:

Cannot find module '@schematics/angular/third_party/github.com/Microsoft/TypeScript/lib/typescript'

Running npm install -D @angular/cli command turned error into familiar this post error.

After running npm i --save-dev @nativescript/schematics the next error appeared:

Error: Invalid rule result: Instance of class Promise. at t.r.pipe.o.mergeMap.r [as project] (C:\Users\taekw\AppData\Roaming\npm\node_modules\nativescript\node_modules@nativescript\schematics-executor\dist\index.js:250:1038) at t._tryNext (C:\Users\taekw\AppData\Roaming\npm\node_modules\nativescript\node_modules@nativescript\schematics-executor\dist\index.js:30:1878) at t._next (C:\Users\taekw\AppData\Roaming\npm\node_modules\nativescript\node_modules@nativescript\schematics-executor\dist\index.js:30:1780) at t.next (C:\Users\taekw\AppData\Roaming\npm\node_modules\nativescript\node_modules@nativescript\schematics-executor\dist\index.js:16:1093) at e._subscribe (C:\Users\taekw\AppData\Roaming\npm\node_modules\nativescript\node_modules@nativescript\schematics-executor\dist\index.js:74:13873) at e._trySubscribe etc..

AndrePu avatar Nov 08 '19 21:11 AndrePu

Hey @AndrePu , Can you send us your package.json? Can you try updating all of your Angular dependencies (remove your package-lock.json before that) and see if this resolves the issue on your side?

rosen-vladimirov avatar Nov 11 '19 08:11 rosen-vladimirov

I am also have this problem when trying to use the cli to generate a component: Error: Invalid rule result: Instance of class Promise.

I've done all the steps suggested above including updating the angular dependencies.

mchallenger88 avatar Nov 22 '19 15:11 mchallenger88

I created a new project based on this template: tns create --template tns-template-drawer-navigation-ng

Attempted to create a component: tns generate c home/test and received this error: Cannot find module '@schematics/angular/utility/parse-name'

Next ran: npm i --save-dev @nativescript/schematics And then: tns generate c home/test, and received error: Cannot find module '@schematics/angular/utility/parse-name'

Uninstalled @nativescript/schematics Ran npm install -D @angular/cli And then tns generate c home/test and received the error: Cannot find module '@schematics/angular/utility/parse-name'

Installed @nativescript/schematics Ran tns generate c home/test and received: Error: Invalid rule result: Instance of class Promise. at t.r.pipe.o.mergeMap.r [as project] (C:\Users\Mark\AppData\Roaming\npm\node_modules\nativescript\node_modules@nativescript\schematics-executor\dist\index.js:250:1038)

mchallenger88 avatar Nov 23 '19 13:11 mchallenger88

I went back to my old project, and because I had deleted the package-lock.json I decided to run:

npm i @nativescript/angular

And now I can generate a component.

mchallenger88 avatar Nov 23 '19 13:11 mchallenger88

This worked for me. npm i --save-dev @nativescript/schematics

Saved my day. Thank you!

Dyloneus avatar Dec 20 '19 08:12 Dyloneus

typescript has been moved to @schematics/angular/node_modules/typescript/lib/typescript" Find and replace all to the new location.

realivatesolutions avatar Feb 16 '20 12:02 realivatesolutions

hello, I have been trying to install Angular Material in a new Angular 9 project with ng add @angular/material but I am getting this error too: Cannot find module '@schematics/angular/third_party/github.com/Microsoft/TypeScript/lib/typescript'

I have installed the npm i @nativescript/angular and npm install -D @angular/cli but nothing helped so far.

Anybody any idea what else I can try or another way to install Angular Material?

linocatucci avatar Feb 17 '20 17:02 linocatucci

hello, I have been trying to install Angular Material in a new Angular 9 project with ng add @angular/material but I am getting this error too: Cannot find module '@schematics/angular/third_party/github.com/Microsoft/TypeScript/lib/typescript'

I have installed the npm i @nativescript/angular and npm install -D @angular/cli but nothing helped so far.

Anybody any idea what else I can try or another way to install Angular Material?

typescript has been moved to @schematics/angular/node_modules/typescript/lib/typescript" Find and replace all to the new location.

realivatesolutions avatar Feb 17 '20 22:02 realivatesolutions

hello, I have been trying to install Angular Material in a new Angular 9 project with ng add @angular/material but I am getting this error too: Cannot find module '@schematics/angular/third_party/github.com/Microsoft/TypeScript/lib/typescript' I have installed the npm i @nativescript/angular and npm install -D @angular/cli but nothing helped so far. Anybody any idea what else I can try or another way to install Angular Material?

typescript has been moved to @schematics/angular/node_modules/typescript/lib/typescript" Find and replace all to the new location.

@realivatesolutions thank you!

linocatucci avatar Feb 18 '20 08:02 linocatucci

Hi @kdmakwana43,

Does your project have a dependency on @angular/cli? The @nativescript/schematics package tries to require a utility function from @schematics/angular. @schematics/angular is a dependency of @angular/cli. To fix the error, install the Angular CLI in your project:

npm install -D @angular/cli

This working for me !

jovanymezura avatar Mar 22 '20 17:03 jovanymezura

npm install -D @angular/cli npm i --save-dev @nativescript/schematics

These two commands also helped me

Comfie avatar Jun 09 '20 22:06 Comfie

when I try to add --> ng add @angular/material to my new project throwing me a error Cannot find module '@schematics/angular/utility/project' Require stack:

  • D:\Web_portal\Web_portal\webangular\node_modules@angular\cdk\schematics\utils\build-component.js
  • D:\Web_portal\Web_portal\webangular\node_modules@angular\cdk\schematics\utils\index.js
  • D:\Web_portal\Web_portal\webangular\node_modules@angular\material\schematics\ng-add\setup-project.js
  • D:\Web_portal\Web_portal\webangular\node_modules@angular-devkit\schematics\tools\export-ref.js
  • D:\Web_portal\Web_portal\webangular\node_modules@angular-devkit\schematics\tools\index.js
  • D:\Web_portal\Web_portal\webangular\node_modules@angular\cli\utilities\json-schema.js
  • D:\Web_portal\Web_portal\webangular\node_modules@angular\cli\models\command-runner.js
  • D:\Web_portal\Web_portal\webangular\node_modules@angular\cli\lib\cli\index.js
  • C:\Users\Minisha\AppData\Roaming\npm\node_modules@angular\cli\lib\init.js
  • C:\Users\Minisha\AppData\Roaming\npm\node_modules@angular\cli\bin\ng

Anyone help me how to solve it.

MinishaFinsurge avatar Jun 11 '20 07:06 MinishaFinsurge

I am experiencing the same issue but with normal ng generate component command.

ayush-codebase avatar Jun 25 '20 20:06 ayush-codebase

Same issue with ng generate component.

th3hunter avatar Jun 25 '20 21:06 th3hunter

Same issue with ng generate component.

Inspecting an old project, found "project.d.ts" and "project.js" under "@schematics\angular\utility". Just copied those 2 files to my new project, and it worked. Surely not a good practice tho.

th3hunter avatar Jun 25 '20 21:06 th3hunter

Same issue with ng g c newcomponent

I tried all previous steps but nothing worked for me

Nasma-Izazi avatar Jun 27 '20 08:06 Nasma-Izazi

Trying to add a component with: ng generate component my-name

I get this:

An unhandled exception occurred: Cannot find module '@schematics/angular/utility/project'
Require stack:
- C:\Users\Me\Documents\Prog\Crossplat\my-angular-app\node_modules\@nativescript\schematics\src\angular-project-parser.js
- C:\Users\Me\Documents\Prog\Crossplat\my-angular-app\node_modules\@nativescript\schematics\src\generate\component\index.js
- C:\Users\Me\Documents\Prog\Crossplat\my-angular-app\node_modules\@angular-devkit\schematics\tools\export-ref.js
- C:\Users\Me\Documents\Prog\Crossplat\my-angular-app\node_modules\@angular-devkit\schematics\tools\index.js
- C:\Users\Me\Documents\Prog\Crossplat\my-angular-app\node_modules\@angular\cli\utilities\json-schema.js
- C:\Users\Me\Documents\Prog\Crossplat\my-angular-app\node_modules\@angular\cli\models\command-runner.js
- C:\Users\Me\Documents\Prog\Crossplat\my-angular-app\node_modules\@angular\cli\lib\cli\index.js
- C:\Users\Me\AppData\Roaming\npm\node_modules\@angular\cli\lib\init.js
- C:\Users\Me\AppData\Roaming\npm\node_modules\@angular\cli\bin\ng

These are my current versions: Angular: 9.1.11 Angular CLI: 10.0.0 Node: 12.18.1

Something about the Schematics that screw this up it seems...

Holei94 avatar Jun 27 '20 09:06 Holei94

@Holei94 I had the same issue after updating my @angular/cli dependency to v 10.0.0 (like you). I just tried it against v 9.1.8 and it worked.

I also tried the various other suggestions, such as installing @schematics/angular, but no luck. Might be an issue with the latest angular cli (v10+).

TLDR: I downgraded to v 9.x.x of the @angular/cli and thereafter ng generate component abc worked.

mikstur avatar Jun 28 '20 08:06 mikstur

An unhandled exception occurred: Cannot find module '@schematics/angular/utility/project'

Hi all. I have to write this due to I can figure out how to fix this problem. When I try to generate a component I have an issue:

ng g c challenges/challenge-edit

Then I get this:

An unhandled exception occurred: Cannot find module '@schematics/angular/utility/project' Require stack:

  • C:\Users\julia\Desktop\PROGRAMMING\UDEMY\ANGULAR\MAXIMILIAN SCH\NATIVESCRIPT\PROJECTS\RoutingANDNavigation\node_modules@nativescript\schematics\src\angular-project-parser.js
  • C:\Users\julia\Desktop\PROGRAMMING\UDEMY\ANGULAR\MAXIMILIAN SCH\NATIVESCRIPT\PROJECTS\RoutingANDNavigation\node_modules@nativescript\schematics\src\generate\component\index.js
  • C:\Users\julia\Desktop\PROGRAMMING\UDEMY\ANGULAR\MAXIMILIAN SCH\NATIVESCRIPT\PROJECTS\RoutingANDNavigation\node_modules@angular-devkit\schematics\tools\export-ref.js
  • C:\Users\julia\Desktop\PROGRAMMING\UDEMY\ANGULAR\MAXIMILIAN SCH\NATIVESCRIPT\PROJECTS\RoutingANDNavigation\node_modules@angular-devkit\schematics\tools\index.js
  • C:\Users\julia\Desktop\PROGRAMMING\UDEMY\ANGULAR\MAXIMILIAN SCH\NATIVESCRIPT\PROJECTS\RoutingANDNavigation\node_modules@angular\cli\utilities\json-schema.js
  • C:\Users\julia\Desktop\PROGRAMMING\UDEMY\ANGULAR\MAXIMILIAN SCH\NATIVESCRIPT\PROJECTS\RoutingANDNavigation\node_modules@angular\cli\models\command-runner.js
  • C:\Users\julia\Desktop\PROGRAMMING\UDEMY\ANGULAR\MAXIMILIAN SCH\NATIVESCRIPT\PROJECTS\RoutingANDNavigation\node_modules@angular\cli\lib\cli\index.js
  • C:\Users\julia\AppData\Roaming\npm\node_modules@angular\cli\lib\init.js
  • C:\Users\julia\AppData\Roaming\npm\node_modules@angular\cli\bin\ng See "C:\Users\julia\AppData\Local\Temp\ng-qOzXJZ\angular-errors.log" for further details.

I have tried to run the commands above:

npm install -D @angular/cli npm i --save-dev @nativescript/schematics

But unfortunately the issue persist

To be honest I do not know what is the problem, I am running Angular CLI: 10.0.1 npm 6.14.5 nativeScript 6.7.4

I would appreciate any help to fix it.

ProgrammerRomero avatar Jul 02 '20 12:07 ProgrammerRomero

An unhandled exception occurred: Cannot find module '@schematics/angular/utility/project'

Hi all. I have to write this due to I can figure out how to fix this problem. When I try to generate a component I have an issue:

ng g c challenges/challenge-edit

Then I get this:

An unhandled exception occurred: Cannot find module '@schematics/angular/utility/project' Require stack:

  • C:\Users\julia\Desktop\PROGRAMMING\UDEMY\ANGULAR\MAXIMILIAN SCH\NATIVESCRIPT\PROJECTS\RoutingANDNavigation\node_modules@nativescript\schematics\src\angular-project-parser.js
  • C:\Users\julia\Desktop\PROGRAMMING\UDEMY\ANGULAR\MAXIMILIAN SCH\NATIVESCRIPT\PROJECTS\RoutingANDNavigation\node_modules@nativescript\schematics\src\generate\component\index.js
  • C:\Users\julia\Desktop\PROGRAMMING\UDEMY\ANGULAR\MAXIMILIAN SCH\NATIVESCRIPT\PROJECTS\RoutingANDNavigation\node_modules@angular-devkit\schematics\tools\export-ref.js
  • C:\Users\julia\Desktop\PROGRAMMING\UDEMY\ANGULAR\MAXIMILIAN SCH\NATIVESCRIPT\PROJECTS\RoutingANDNavigation\node_modules@angular-devkit\schematics\tools\index.js
  • C:\Users\julia\Desktop\PROGRAMMING\UDEMY\ANGULAR\MAXIMILIAN SCH\NATIVESCRIPT\PROJECTS\RoutingANDNavigation\node_modules@angular\cli\utilities\json-schema.js
  • C:\Users\julia\Desktop\PROGRAMMING\UDEMY\ANGULAR\MAXIMILIAN SCH\NATIVESCRIPT\PROJECTS\RoutingANDNavigation\node_modules@angular\cli\models\command-runner.js
  • C:\Users\julia\Desktop\PROGRAMMING\UDEMY\ANGULAR\MAXIMILIAN SCH\NATIVESCRIPT\PROJECTS\RoutingANDNavigation\node_modules@angular\cli\lib\cli\index.js
  • C:\Users\julia\AppData\Roaming\npm\node_modules@angular\cli\lib\init.js
  • C:\Users\julia\AppData\Roaming\npm\node_modules@angular\cli\bin\ng See "C:\Users\julia\AppData\Local\Temp\ng-qOzXJZ\angular-errors.log" for further details.

I have tried to run the commands above:

npm install -D @angular/cli npm i --save-dev @nativescript/schematics

But unfortunately the issue persist

To be honest I do not know what is the problem, I am running Angular CLI: 10.0.1 npm 6.14.5 nativeScript 6.7.4

I would appreciate any help to fix it.

Downgrade @angular/cli to 9.1.8, just as above poster said.

th3hunter avatar Jul 02 '20 15:07 th3hunter

An unhandled exception occurred: Cannot find module '@schematics/angular/utility/project'

Hi all. I have to write this due to I can figure out how to fix this problem. When I try to generate a component I have an issue: ng g c challenges/challenge-edit Then I get this:

An unhandled exception occurred: Cannot find module '@schematics/angular/utility/project' Require stack:

  • C:\Users\julia\Desktop\PROGRAMMING\UDEMY\ANGULAR\MAXIMILIAN SCH\NATIVESCRIPT\PROJECTS\RoutingANDNavigation\node_modules@nativescript\schematics\src\angular-project-parser.js
  • C:\Users\julia\Desktop\PROGRAMMING\UDEMY\ANGULAR\MAXIMILIAN SCH\NATIVESCRIPT\PROJECTS\RoutingANDNavigation\node_modules@nativescript\schematics\src\generate\component\index.js
  • C:\Users\julia\Desktop\PROGRAMMING\UDEMY\ANGULAR\MAXIMILIAN SCH\NATIVESCRIPT\PROJECTS\RoutingANDNavigation\node_modules@angular-devkit\schematics\tools\export-ref.js
  • C:\Users\julia\Desktop\PROGRAMMING\UDEMY\ANGULAR\MAXIMILIAN SCH\NATIVESCRIPT\PROJECTS\RoutingANDNavigation\node_modules@angular-devkit\schematics\tools\index.js
  • C:\Users\julia\Desktop\PROGRAMMING\UDEMY\ANGULAR\MAXIMILIAN SCH\NATIVESCRIPT\PROJECTS\RoutingANDNavigation\node_modules@angular\cli\utilities\json-schema.js
  • C:\Users\julia\Desktop\PROGRAMMING\UDEMY\ANGULAR\MAXIMILIAN SCH\NATIVESCRIPT\PROJECTS\RoutingANDNavigation\node_modules@angular\cli\models\command-runner.js
  • C:\Users\julia\Desktop\PROGRAMMING\UDEMY\ANGULAR\MAXIMILIAN SCH\NATIVESCRIPT\PROJECTS\RoutingANDNavigation\node_modules@angular\cli\lib\cli\index.js
  • C:\Users\julia\AppData\Roaming\npm\node_modules@angular\cli\lib\init.js
  • C:\Users\julia\AppData\Roaming\npm\node_modules@angular\cli\bin\ng See "C:\Users\julia\AppData\Local\Temp\ng-qOzXJZ\angular-errors.log" for further details.

I have tried to run the commands above: npm install -D @angular/cli npm i --save-dev @nativescript/schematics But unfortunately the issue persist To be honest I do not know what is the problem, I am running Angular CLI: 10.0.1 npm 6.14.5 nativeScript 6.7.4 I would appreciate any help to fix it.

Downgrade @angular/cli to 9.1.8, just as above poster said.

Thanks dude. Gracias amigo.

I Downgraded just the dependency @schematics and it works now.

npm uninstall @schematics/angular
npm cache clean
npm install @schematics/[email protected]

ProgrammerRomero avatar Jul 04 '20 14:07 ProgrammerRomero

the normal solution to try is :

npm install -D @angular/cli

make sure you have nativescript/schematics in your package.json . otherwise add it with :

npm i --save-dev @nativescript/schematics

if you still get the same problem, this because you have incompatible version between dependencies ,for example @angular/[email protected] and nativescript/[email protected] . in this case you have to downgrade the appropriate dependency to 9.x.x :

npm uninstall @schematics/angular npm cache clean npm install @schematics/[email protected]

hamdirhibi avatar Jul 04 '20 22:07 hamdirhibi