Bila nak start process ionic serve, aku dapat error macam di bawah.
$ ionic serve > ng run app:serve --host=localhost --port=8100 [ng] internal/modules/cjs/loader.js:796 [ng] throw err; [ng] ^ [ng] Error: Cannot find module '../lib/init' [ng] Require stack: [ng] - /Users/azmim/Code/learnIONIC/ionic/project02/node_modules/.bin/ng [ng] at Function.Module._resolveFilename (internal/modules/cjs/loader.js:793:17) [ng] at Function.Module._load (internal/modules/cjs/loader.js:686:27) [ng] at Module.require (internal/modules/cjs/loader.js:848:19) [ng] at require (internal/modules/cjs/helpers.js:74:18) [ng] at Object.<anonymous> (/Users/azmim/Code/learnIONIC/ionic/project02/node_modules/.bin/ng:27:3) [ng] at Module._compile (internal/modules/cjs/loader.js:955:30) [ng] at Object.Module._extensions..js (internal/modules/cjs/loader.js:991:10) [ng] at Module.load (internal/modules/cjs/loader.js:811:32) [ng] at Function.Module._load (internal/modules/cjs/loader.js:723:14) [ng] at Function.Module.runMain (internal/modules/cjs/loader.js:1043:10) { [ng] code: 'MODULE_NOT_FOUND', [ng] requireStack: [ [ng] '/Users/azmim/Code/learnIONIC/ionic/project02/node_modules/.bin/ng' [ng] ] [ng] } [ERROR] ng has unexpectedly closed (exit code 1). The Ionic CLI will exit. Please check any output above for error details.
Jadi isu ini jadi bila aku copy project ini dari directory dan segala node_modules cuma kenal libraries dan module dalam path directory tersebut jadi apabila dia dipindahkan ke directory path dah jadi lain.
Jadi apa yang aku cuba aku buang semua node_modules dan package-lock.json file dan reinstall semula modules & package.
$ rm -rf node_modules; rm -f package-lock.json; npm install
Apabila npm install di”execute”, dia akan refer balik file package.json untuk install semula segala packages & module yang dah remove tadi.