Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot find module @angular\cli\bin\ng

I'm getting into trouble with anngular-cli installation because it doesn't recognize the ng command in my git bash but it works in my cmd on Windows 7.

I looked for some issues on the web but I didn't really find a solution.

Here, the error :

   ng -v    module.js:549     throw err;     ^     Error: Cannot find module 'C:\Program     Files\Git\node_modules\@angular\cli\bin\ng'     at Function.Module._resolveFilename (module.js:547:15)     at Function.Module._load (module.js:474:25)     at Function.Module.runMain (module.js:693:10)     at startup (bootstrap_node.js:191:16)     at bootstrap_node.js:612:3 

This error happened the first time I used ng after installing Node and angular-cli globally.

I didn't get this error when I was working on my laptop on Windows 10.

like image 924
Romain Rnd Avatar asked Aug 07 '18 12:08

Romain Rnd


People also ask

Can not find module in angular?

To solve the error "Cannot find module '@angular/core'", make sure you have installed all dependencies by running the npm install command, set the baseUrl option to src in your tsconfig. json file and restart your IDE and development server. Copied!

Can not find node module?

If you are getting the "Cannot find module" error when trying to run a local file, make sure that the path you passed to the node command points to a file that exists. For example, if you run node src/index. js , make sure that the path src/index. js points to an existing file.

Can't find module angular Devkit build angular?

To solve the error "Could not find module '@angular-devkit/build-angular'", make sure to install the package by opening your terminal in your project's root directory and running the following command: npm i -D @angular-devkit/build-angular and restart your IDE and development server.

How do you solve ng error?

To solve the error "ng: command not found", install the angular cli package globally by running npm install -g @angular/cli@latest and restart your terminal. If the command fails, run it with sudo and make sure the correct PATH is set in your system's environment variable.


2 Answers

Problem:

Error: Cannot find module '..\AppData\Roaming\npm\node_modules\angular-cli\bin\ng' angularJs

Solution:

  1. uninstall angular cli if you have already installed it

    npm uninstall -g @angular/cli 
  2. Delete the C:\Users\Satish\AppData\Roaming\npm\node_modules@angular folder if it still exists after the uninstall

  3. reinstall angular-cli globally

    npm install -g @angular/cli 
like image 85
M A Azad Avatar answered Oct 11 '22 09:10

M A Azad


It worked for me only by removing npm and npm-cache folders from AppData then running :

npm uninstall -g @angular/cli 

Then running :

npm install -g @angular/cli 
like image 24
elmaystro Avatar answered Oct 11 '22 10:10

elmaystro