Installed the latest stable version of node/npm and angular cli (both globally). My angular projects are working fine (i.e. ng serve works fine).
$ node -v
v12.14.0
$ npm -v
6.13.4
Then i installed ionic - npm install – g ionic
Then created my ionic project and ran ionic serve. But it throws an error:
ng run app:serve --host=0.0.0.0 --port=8100
[ng] The system cannot find the path specified.
[ng] internal/modules/cjs/loader.js:800
[ng] throw err;
[ng] ^
[ng] Error: Cannot find module ‘D:\0. Mayank 2020 - Laptop@angular\cli\bin\ng’
[ng] at Function.Module._resolveFilename (internal/modules/cjs/loader.js:797:15)
[ng] at Function.Module._load (internal/modules/cjs/loader.js:690:27)
[ng] at Function.Module.runMain (internal/modules/cjs/loader.js:1047:10)
[ng] at internal/main/run_main_module.js:17:11 {
[ng] code: ‘MODULE_NOT_FOUND’,
[ng] requireStack:
[ng] }
[ERROR] ng has unexpectedly closed (exit code 1).
The Ionic CLI will exit. Please check any output above for error details.
Thereafter I installed an earlier version of ionic - i.e. 4,12,0. But the error persists.
I am using Git Bash terminal on windows. Tried the same in command prompt too but the same error is thrown.
My package.json file:
{
“name”: “hello-world2”,
“version”: “0.0.1”,
“author”: “Ionic Framework”,
“homepage”: “https://ionicframework.com/”,
“scripts”: {
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"
},
“private”: true,
“dependencies”: {
"@angular/common": "~8.1.2",
"@angular/core": "~8.1.2",
"@angular/forms": "~8.1.2",
"@angular/platform-browser": "~8.1.2",
"@angular/platform-browser-dynamic": "~8.1.2",
"@angular/router": "~8.1.2",
"@ionic-native/core": "^5.0.0",
"@ionic-native/splash-screen": "^5.0.0",
"@ionic-native/status-bar": "^5.0.0",
"@ionic/angular": "^4.7.1",
"core-js": "^2.5.4",
"rxjs": "~6.5.1",
"tslib": "^1.9.0",
"zone.js": "~0.9.1"
},
“devDependencies”: {
"@angular-devkit/architect": "~0.801.2",
"@angular-devkit/build-angular": "~0.801.2",
"@angular-devkit/core": "~8.1.2",
"@angular-devkit/schematics": "~8.1.2",
"@angular/cli": "~8.1.2",
"@angular/compiler": "~8.1.2",
"@angular/compiler-cli": "~8.1.2",
"@angular/language-service": "~8.1.2",
"@ionic/angular-toolkit": "^2.1.1",
"@types/jasmine": "~3.3.8",
"@types/jasminewd2": "~2.0.3",
"@types/node": "~8.9.4",
"codelyzer": "^5.0.0",
"jasmine-core": "~3.4.0",
"jasmine-spec-reporter": "~4.2.1",
"karma": "~4.1.0",
"karma-chrome-launcher": "~2.2.0",
"karma-coverage-istanbul-reporter": "~2.0.1",
"karma-jasmine": "~2.0.1",
"karma-jasmine-html-reporter": "^1.4.0",
"protractor": "~5.4.0",
"ts-node": "~7.0.0",
"tslint": "~5.15.0",
"typescript": "~3.4.3"
},
“description”: “An Ionic project”
}