angular-cli icon indicating copy to clipboard operation
angular-cli copied to clipboard

ng serve not working when install latest version of angular cli

Open tedrob opened this issue 9 years ago • 43 comments

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.

tedrob avatar Feb 22 '17 01:02 tedrob

@tedrob can you please enter the information requested in the template? It looks like you posted just the template without entering the details. Thanks!

beeman avatar Feb 22 '17 01:02 beeman

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

beeman avatar Feb 22 '17 01:02 beeman

I removed node-modules and still get the error can't find from '@angular/platform-browser-dynamic';

tedrob avatar Feb 22 '17 01:02 tedrob

also when I run ng serve I can't find Tried to find bootstrap code, but could not

tedrob avatar Feb 22 '17 01:02 tedrob

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'

bdelaney avatar Feb 22 '17 01:02 bdelaney

What is the output of this:

npm ls @angular/platform-browser-dynamic

beeman avatar Feb 22 '17 01:02 beeman

-- @angular/[email protected]

tedrob avatar Feb 22 '17 02:02 tedrob

now I get this error ERROR in ./src/main.ts Module build failed: TypeError: Cannot read property 'newLine' of undefined at Object.getNewLineCharacter (C:\aaa-angular2\foundation\ag2-tubes\node_modules\typescript\lib\typescript.js:8062:20) at Object.createCompilerHost (C:\aaa-angular2\foundation\ag2-tubes\node_modules\typescript\lib\typescript.js:44978:26) at Object.ngcLoader (C:\aaa-angular2\foundation\ag2-tubes\node_modules@ngtools\webpack\src\loader.js:350:33) @ multi webpack-dev-server/client?http://localhost:4200/ ./src/main.ts

tedrob avatar Feb 22 '17 02:02 tedrob

I tried that and still get the same problem, but when you say you renamed angular-cli.json to begin with a . do you mean .angular-cli.json

or angular.cli.json

Which is it?

tedrob avatar Feb 22 '17 03:02 tedrob

OK I renamed angular-cli.json to .angular-cli.json but still get this error ERROR in ./src/main.ts Module build failed: TypeError: Cannot read property 'newLine' of undefined at Object.getNewLineCharacter (C:\aaa-angular2\foundation\ag2-tubes\node_modules\typescript\lib\typescript.js:8062:20) at Object.createCompilerHost (C:\aaa-angular2\foundation\ag2-tubes\node_modules\typescript\lib\typescript.js:44978:26) at Object.ngcLoader (C:\aaa-angular2\foundation\ag2-tubes\node_modules@ngtools\webpack\src\loader.js:350:33) @ multi webpack-dev-server/client?http://localhost:4200/ ./src/main.ts

tedrob avatar Feb 22 '17 05:02 tedrob

@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.

bdelaney avatar Feb 22 '17 11:02 bdelaney

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.

dxxvi avatar Feb 22 '17 15:02 dxxvi

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"
}

rahulraocoder avatar Feb 24 '17 17:02 rahulraocoder

ng serve is not serving old angular2 projects.

rahulraocoder avatar Feb 24 '17 17:02 rahulraocoder

@rahulroxx the suggested fix is printed there.

beeman avatar Feb 24 '17 17:02 beeman

I did the same but throws new error as posted by @tedrob

Module build failed: TypeError: Cannot read property 'newLine' of undefined
at Object.getNewLineCharacter (C:\aaa-angular2\foundation\ag2-tubes\node_modules\typescript\lib\typescript.js:8062:20)
at Object.createCompilerHost (C:\aaa-angular2\foundation\ag2-tubes\node_modules\typescript\lib\typescript.js:44978:26)
at Object.ngcLoader (C:\aaa-angular2\foundation\ag2-tubes\node_modules@ngtools\webpack\src\loader.js:350:33)
@ multi webpack-dev-server/client?http://localhost:4200/ ./src/main.ts

rahulraocoder avatar Feb 24 '17 17:02 rahulraocoder

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

beeman avatar Feb 24 '17 19:02 beeman

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

svcastaneda avatar Feb 27 '17 19:02 svcastaneda

I'm facing this same problem after upgrading from beta24, and followed each breaking change step in the changelog.

I uninstalled everything as @beeman suggested, and see the newLine error.

@angular/cli: 1.0.0-rc.0
node: 6.9.2
os: darwin x64
@angular/common: 2.4.7
@angular/compiler: 2.4.7
@angular/compiler-cli: 2.4.7
@angular/core: 2.4.7
@angular/forms: 2.4.7
@angular/http: 2.4.7
@angular/platform-browser: 2.4.7
@angular/platform-browser-dynamic: 2.4.7
@angular/router: 3.4.7
@angular/cli: 1.0.0-rc.0

Error

ERROR in ./src/main.ts
Module build failed: TypeError: Cannot read property 'newLine' of undefined
    at Object.getNewLineCharacter (/.../node_modules/typescript/lib/typescript.js:9426:20)
    at Object.createCompilerHost (/.../node_modules/typescript/lib/typescript.js:62475:26)
    at Object.ngcLoader (/.../node_modules/@ngtools/webpack/src/loader.js:341:33)
 @ multi webpack-dev-server/client?http://localhost:4200 ./src/main.ts
webpack: Failed to compile.

gnomeontherun avatar Mar 01 '17 17:03 gnomeontherun

@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"
}

gnomeontherun avatar Mar 01 '17 23:03 gnomeontherun