Search code examples
javascriptnode.jsangularnode-modulesnpm-publish

unable to run any angular project after changing angular version


My project was running completely ok , but today due to some other projects i did had to change the angular version , due to compatibility issues , but anyhow i was able to change versions using nvm use but after i could'nt build my any angular projects . this is the error i get when i run the command

ng serve

$ ng serve 
bash: ng: command not found

node version

node:internal/modules/cjs/loader:1078
  throw err;
  ^

Error: Cannot find module 'C:\Users\Standard User\Desktop\demo\DatingApp\client\version'
←[90m    at Module._resolveFilename (node:internal/modules/cjs/loader:1075:15)←[39m
←[90m    at Module._load (node:internal/modules/cjs/loader:920:27)←[39m
←[90m    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)←[39m
←[90m    at node:internal/main/run_main_module:23:47←[39m {
  code: ←[32m'MODULE_NOT_FOUND'←[39m,
  requireStack: []
}

Node.js v18.16.0

I've seen that this issue i'm faceing is very popular and faced by so many peoples , i'm very new to angular,so i find difficulty in versioning . bcz angular has so many versions and i've tried many aprroaches to solve this error which was mentioned already here and github.


Solution

  • First you need to clean the cache from run this command below:

    npm cache clean --force
    

    Then after you need to re install the Angular from this command below:

    npm install -g @angular/cli