ng serve command not working angular 5
Solution 1
This could be due to different versions of angular-cli. Check the version of angular-cli, you should not have version 6, but use 1.7. Cause in angular 6 the configuration is in angular.json file. In version 1.7 the configuration is in angular-cli.json
Solution 2
> npm start
will solve your problem as it solved mine
mjck
I am a front end developer, working in web development since 8 years, initially i started with PHP development, now full time working on front end.
Updated on July 18, 2022Comments
-
mjck almost 2 years
If I run ng serve, getting this error
ng : The term 'ng' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. At line:1 char:1 + ng serve + ~~ + CategoryInfo : ObjectNotFound: (ng:String) [], CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException
I have tried npm run ng serve, getting this error
Local workspace file ('angular.json') could not be found. Error: Local workspace file ('angular.json') could not be found. at WorkspaceLoader._getProjectWorkspaceFilePath (C:\Users\rohit\AppData\Roaming\npm\node_modules\@angular\cli\models\workspace-loader.js:3 7:19) at WorkspaceLoader.loadWorkspace (C:\Users\rohit\AppData\Roaming\npm\node_modules\@angular\cli\models\workspace-loader.js:24:21) at ServeCommand._loadWorkspaceAndArchitect (C:\Users\rohit\AppData\Roaming\npm\node_modules\@angular\cli\models\architect-command.js:180:3 2) at ServeCommand. (C:\Users\rohit\AppData\Roaming\npm\node_modules\@angular\cli\models\architect-command.js:47:25) at Generator.next () at C:\Users\rohit\AppData\Roaming\npm\node_modules\@angular\cli\models\architect-command.js:7:71 at new Promise () at __awaiter (C:\Users\rohit\AppData\Roaming\npm\node_modules\@angular\cli\models\architect-command.js:3:12) at ServeCommand.initialize (C:\Users\rohit\AppData\Roaming\npm\node_modules\@angular\cli\models\architect-command.js:46:16) at Object. (C:\Users\rohit\AppData\Roaming\npm\node_modules\@angular\cli\models\command-runner.js:87:23) npm ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR! [email protected] ng:
ng "serve"
npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the [email protected] ng script. npm ERR! This is probably not a problem with npm. There is likely additional logging output above.npm ERR! A complete log of this run can be found in: npm ERR! C:\Users\rohit\AppData\Roaming\npm-cache\_logs\2018-06-12T06_59_12_392Z-debug.log
I have uninstall @angular/cli and cleared the cached, again installed but facing same issue.
Kindly suggest.
-
Parth Savadiya almost 6 yearsIt gave error because you installed latest version of Angular CLI and your project built with may be older version of angular Try to run: npm install -g @angular/[email protected]
-
mjck almost 6 yearsThanks for reponse, I tried this but facing same issue
-
Admin almost 6 years
npm i -g @angular/cli
, or if it's installed locally, try runningnpm run serve
after you added"serve": "ng serve"
to your package file -
Parth Savadiya almost 6 yearsFrom which path you are trying to run? that path contain package.json and angular.json file?
-
mjck almost 6 yearswhere I can see the path or update
-
-
Admin almost 6 yearsThis should be a comment
-
mjck almost 6 yearsThanks for the update, I have installed npm install -g @angular/[email protected], removed the node modules folder and installed it again. if I run npm run ng serve its working fine, but if I run ng serve its not working
-
Sudhir Kaushik over 5 yearsI challenge this solution. If we look at the documentation and other online articles, angular-cli 1.7 contains vulnerabilities, due to which latest version of angular-cli is preferred. Answer is Okay if you are not putting something in production.
-
DevSay about 3 yearsWorked for me. Thank you