简体   繁体   中英

ng serve is not working even if I update everything

   $ ng serve
    ENOENT: no such file or directory, stat 'E:\Work\Angular\Basic website\Angular 4\my-first-app\src\tsconfig.json'
    Error: ENOENT: no such file or directory, stat 'E:\Work\Angular\Basic website\Angular 4\my-first-app\src\tsconfig.json'
        at Error (native)
        at Object.fs.statSync (fs.js:1000:11)
        at AotPlugin._setupOptions (E:\Work\Angular\Basic website\Angular 4\my-first-app\node_modules\@ngtools\webpack\src\plugin.js:62:16)
        at new AotPlugin (E:\Work\Angular\Basic website\Angular 4\my-first-app\node_modules\@ngtools\webpack\src\plugin.js:27:14)
        at _createAotPlugin (E:\Work\Angular\Basic website\Angular 4\my-first-app\node_modules\@angular\cli\models\webpack-configs\typescript.js:55:12)
        at Object.exports.getNonAotConfig (E:\Work\Angular\Basic website\Angular 4\my-first-app\node_modules\@angular\cli\models\webpack-configs\typescript.js:71:19)
        at NgCliWebpackConfig.buildConfig (E:\Work\Angular\Basic website\Angular 4\my-first-app\node_modules\@angular\cli\models\webpack-config.js:29:37)
        at Class.run (E:\Work\Angular\Basic website\Angular 4\my-first-app\node_modules\@angular\cli\tasks\serve.js:43:98)
        at check_port_1.checkPort.then.port (E:\Work\Angular\Basic website\Angular 4\my-first-app\node_modules\@angular\cli\commands\serve.js:114:26)
        at process._tickCallback (internal/process/next_tick.js:109:7)

When I hit ng serve on cmd it's not working although its working 1st & 2nd time but its not working now. All things are running perfectly. eg ng --version .. the problem is only with ng serve ..it only runs for the 1st & 2nd time..

try update your angular-cli global:

npm uninstall -g @angular/cli
npm cache clean
npm install -g @angular/cli@latest

Then exclude the node_modules folder.

Change the angular-cli dev dependency version of your package.json , according with the ng --version :

angular-cli 开发依赖版本

Finally run npm install and after run ng serve --open .

First check your folder structure.. In angular-cli 0.0.30 there's a client folder between src/ and app. So now, when you generate a project, it's src/client/app not src/app. So, if you're upgrading the CLI for an existing project, please add that folder manually and move app inside of the new client dir. See a5ddd75 for more information

Credits to Leonard Oliveira, https://stackoverflow.com/users/4920091/leonardo-oliveira .

If you dont want to uninstall your angular compiler. just go to the project and do the following: npm install npm cache clean npm audit fix

It should work fine.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM