angular-cli: ng serve not working when install latest version of angular cli

Please provide us with the following information: windows 10

angular/cli: 1.0.0-beta.32.3 [1.0.0-beta.26] node: 6.9.5 os: win32 x64 @angular/cli: 1.0.0-beta.32.3

nothing just upgraded to the new version and started having all these problems also I get this error also can’t find @angular/platform-browser-dynamic


OS?

Windows 7, 8 or 10. Linux (which distribution). Mac OSX (Yosemite? El Capitan?)

Versions.

Please run ng --version. If there’s nothing outputted, please run in a Terminal: node --version and paste the result here:

Repro steps.

Was this an app that wasn’t created using the CLI? What change did you do on your code? etc.

The log given by the failure.

Normally this include a stack trace and some more information.

Mention any other details that might be useful.


Thanks! We’ll be in touch soon.

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Comments: 43 (7 by maintainers)

Most upvoted comments

Try these steps please:

Clean up

  • remove node_modules from your project
  • remove any angular-cli and @angular/cli references from package.json if it’s there
  • Uninstall angular-cli and @angular/cli globally: npm uninstall -g angular-cli @angular/cli

Reinstall

  • Install @angular/cli globally: npm install -g @angular/cli
  • Install @angular/cli in your project: npm install --save-dev @angular/cli

On a Windows 7, 64bit

rm -rf node_modules
npm install
ng serve

solved it. 🚀

@khizerrehands You need to follow the environments portion of the angular-cli.json file just like it mentions in the error. Replace the environments property with these two.

"environmentSource": "environments/environment.ts",
"environments": {
  "dev": "environments/environment.ts",
  "prod": "environments/environment.prod.ts"
}

Hi,

Found the solution. If you the error above still persist then try this:

open angular-cli.json find- “environments”: { “source”: “environments/environment.ts”, “dev”: “environments/environment.ts”, “prod”: “environments/environment.prod.ts” }

and replace with: “environmentSource”: “environments/environment.ts”, “environments”: { “dev”: “environments/environment.ts”, “prod”: “environments/environment.prod.ts” }

@tedrob - sorry my comment came in as exact same time as @beeman. I did not have a solution or good troubleshooting. Just figured that in my case (.26 -> 32.3), the new version has so many breaking changes that I may as well give up on the old project and have ngCLI build a new one, then transfer module code etc into that new project. I apologize for confusing this thread.

I guess we cannot expect upgrade stability until we get to RC stage at least.

@tedrob can you try to remove node_modules from you project and run npm install again?

If @beeman’s steps don’t work, check which version of node you’re using.

Steps:

  • node -v should be v6.9.0 or higher. If not, keep reading.
  • Run nvm ls. The output should look something like this:
$ nvm ls
         v5.0.0
->       v5.9.0
         v6.9.5
         system
default -> node (-> v6.9.5)
node -> stable (-> v6.9.5) (default)
stable -> 6.9 (-> v6.9.5) (default)
iojs -> N/A (default)
  • If v6.9 isn’t installed, run nvm install v6.9
  • Run node -v and check if it’s now using v6.9._. If not, run nvm use 6.9

Same Problem need help

Environment configuration does not contain "environmentSource" entry.

A new environmentSource entry replaces the previous source entry inside environments.

To migrate angular-cli.json follow the example below:

Before:

"environments": {
  "source": "environments/environment.ts",
  "dev": "environments/environment.ts",
  "prod": "environments/environment.prod.ts"
}


After:

"environmentSource": "environments/environment.ts",
"environments": {
  "dev": "environments/environment.ts",
  "prod": "environments/environment.prod.ts"
}

@rahulroxx the suggested fix is printed there.

I have some weird issues with

@angular/cli: 1.0.0-beta.32.3
node: 7.3.0
os: win32 ia32
npm 3.10.10

A new project created with ng new project-name runs fine in Firefox 52.0b7, but doesn’t run in IE 11.0.9600.18537 and Chrome 43.0.2357.134 m which both show an error message “Unable to get property ‘apply’ of undefined or null reference” for this function

function combine(options) {
    return (_a = ((Object))).assign.apply(_a, [{}].concat(options));
    var _a;
}

IE says it’s in vendor.bundle.js, Chrome says it’s in intl.js.

@paulmc it might make sense to open a new issue for that 😃

i have tried all the above solutions still the problem persisits…please help…

Microsoft Windows [Version 10.0.14393] © 2016 Microsoft Corporation. All rights reserved.

C:\Users\Manirish>npm install npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@^1.0.0 (node_modules\chokidar\node_modules\fsevents): npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.1.1: wanted {“os”:“darwin”,“arch”:“any”} (current: {“os”:“win32”,“arch”:“x64”}) npm WARN @angular/core@4.0.1 requires a peer of rxjs@^5.0.1 but none was installed. npm WARN @angular/http@4.0.1 requires a peer of rxjs@^5.0.1 but none was installed. npm WARN @angular/router@4.0.1 requires a peer of rxjs@^5.0.1 but none was installed. npm WARN codelyzer@2.1.1 requires a peer of tslint@^4.0.0 but none was installed.

C:\Users\Manirish>npm start

untitled1@0.0.0 start C:\Users\Manirish ng serve

Environment configuration does not contain “environmentSource” entry.

A new environmentSource entry replaces the previous source entry inside environments.

To migrate angular-cli.json follow the example below:

Before:

“environments”: { “source”: “environments/environment.ts”, “dev”: “environments/environment.ts”, “prod”: “environments/environment.prod.ts” }

After:

“environmentSource”: “environments/environment.ts”, “environments”: { “dev”: “environments/environment.ts”, “prod”: “environments/environment.prod.ts” }

npm ERR! Windows_NT 10.0.14393 npm ERR! argv “C:\Program Files\nodejs\node.exe” “C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js” “start” npm ERR! node v7.8.0 npm ERR! npm v4.2.0 npm ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR! untitled1@0.0.0 start: ng serve npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the untitled1@0.0.0 start script ‘ng serve’. npm ERR! Make sure you have the latest version of node.js and npm installed. npm ERR! If you do, this is most likely a problem with the untitled1 package, npm ERR! not with npm itself. npm ERR! Tell the author that this fails on your system: npm ERR! ng serve npm ERR! You can get information on how to open an issue for this project with: npm ERR! npm bugs untitled1 npm ERR! Or if that isn’t available, you can get their info via: npm ERR! npm owner ls untitled1 npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request: npm ERR! C:\Users\Manirish\AppData\Roaming\npm-cache_logs\2017-04-02T00_45_05_847Z-debug.log

C:\Users\Manirish>

ng serve is not serving old angular2 projects.

I upgraded from a project using CLI beta.26 to 32.3, following directions here to upgrade the cli. At first running NG Serve produced a request to modify the cli json file: “To migrate angular-cli.json follow the example below:” as per the Breaking changes note. Which I did. Then ran ng serve again. That seemed to start the server, but with an error: “ERROR in AppModule is not an NgModule” And browsing to the localhost:4200 gives me: “Cannot GET /” I then manually renamed angular-cli.json to begin with . as mentioned per ‘code refactoring’ same problem ng version output: @angular/cli: 1.0.0-beta.32.3 node: 6.9.5 os: win32 x64 Windows 10

Created new project with ng new and then ran ng serve. Works!

just sayin’