mjck
mjck

Reputation: 197

ng serve command not working angular 5

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.

Upvotes: 2

Views: 17932

Answers (4)

Kondas Lamar Jnr
Kondas Lamar Jnr

Reputation: 143

> npm start

will solve your problem as it solved mine

Upvotes: 4

Dulanga Heshan
Dulanga Heshan

Reputation: 1425

This may work

add your your npm folder path and angular-cli\bin folder path to environment variables

C:\Users\YourPcName\AppData\Roaming\npm`
C:\Users\YoutPcName\AppData\Roaming\npm\node_modules\angular-cli\bin`

Upvotes: 0

Arne
Arne

Reputation: 842

You have two issues here. You are trying to run global angular-cli commands without having the angular cli globally installed. You could solve this by installing the CLI globally using npm i -g @angular/cli The next issue you have is that when using the project angular cli, you upgraded the cli but not the project itself. You can either reinstall an older cli by changing the version in your package.json, or upgrade your package using the awesome new schematics. For this I'd advise you to read the upgrade guide.

If you don't feel like reading, and feel especially lucky today, you can just download the 6.0 cli globally in the way mentioned above, and run ng update

Upvotes: -1

alexKhymenko
alexKhymenko

Reputation: 5598

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

Upvotes: 2

Related Questions