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

scripts.bundle.js net::ERR_ABORTED

Open ylligashi opened this issue 9 years ago • 40 comments

Bug Report or Feature Request (mark with an x)

- [x ] bug report -> please search issues before submitting
- [ ] feature request

Versions.

Angular CLI: 1.5.0 Node: 8.8.0 OS: darwin x64 Angular: 5.0.0 ... animations, common, compiler, compiler-cli, core, forms ... http, platform-browser, platform-browser-dynamic ... platform-server, router

@angular/cli: 1.5.0 @angular/language-service: 4.4.4 @angular-devkit/build-optimizer: 0.0.32 @angular-devkit/core: 0.0.20 @angular-devkit/schematics: 0.0.35 @ngtools/json-schema: 1.1.0 @ngtools/webpack: 1.8.0 @schematics/angular: 0.1.0 typescript: 2.4.2 webpack: 3.8.1

Repro steps.

When I run 'ng serve --aot` it gives me this error: GET http://localhost:4200/scripts.bundle.js net::ERR_ABORTED

and because I have included jquery it has problem referencing it. ERROR ReferenceError: $ is not defined

I checked Network on Dev tools and scripts.bundle.js is NOT FOUND

The log given by the failure.

Desired functionality.

Today I upgraded the project to angular@5 and [email protected] . Prior to this, it did not happen.

Mention any other details that might be useful.

ylligashi avatar Nov 06 '17 13:11 ylligashi

I had the same problem, I solved it by updating node to latest version: https://nodejs.org/en/download/ then "npm cache --force clean" and then "npm install" :)

iosifpetre18 avatar Nov 27 '17 14:11 iosifpetre18

This happens when you use Electron and change index.html <base href="/"> to <base href="./">

Just add useHash:true in your route module

@NgModule({
  imports: [
    BrowserModule,
    FormsModule,
    RouterModule.forRoot(routes, { useHash: true })  // .../#/your-route/
  ]...

ameagol avatar Nov 28 '17 18:11 ameagol

same here: angular cli:1.5.5 angular:5.0.5 node:9.1.0 typescript:2.6.2 webpack:3.8.1 npm cache clean or npm cache verify don't work for me

candy4290 avatar Dec 07 '17 03:12 candy4290

This seems like a bug but we'll need to look at a reproduction to find and fix the problem. Can you setup a minimal repro please?

You can read here why this is needed. A good way to make a minimal repro is to create a new app via ng new repro-app and adding the minimum possible code to show the problem. Then you can push this repository to github and link it here.

filipesilva avatar Dec 07 '17 17:12 filipesilva

Both ng serve --aot and ng build --aot throws hundreds of error TS5055: Cannot write file '/node_modules/zone.js/dist/zone.js' because it would overwrite input file. errors with different files from the /node_modules folder.

Fixed this by removing the "allowJs": true from the tsconfig.json file.

artuska avatar Dec 11 '17 20:12 artuska

I'm running into the same issue after running a prod build with AOT enabled. The project is built on Angular5:

Angular CLI: 1.5.0-rc.3
Node: 6.11.1
OS: win32 x64
Angular: 5.0.0
@angular/cli: 1.5.0-rc.3
@angular-devkit/build-optimizer: 0.0.35
@angular-devkit/core: 0.0.22
@angular-devkit/schematics: 0.0.41
@ngtools/json-schema: 1.1.0
@ngtools/webpack: 1.8.0-rc.3
@schematics/angular: 0.0.49
@schematics/schematics: 0.0.10
typescript: 2.4.2
webpack: 3.8.1

Everything worked fine until I tried running the prod build command (testing the CI build step, basically) in my project folder once.

ng build --base-href /baseuri/ --prod --aot true --output-path %CD%/bin_ci

Afterwards the app still builds and runs but displays the error when running it in a browser.

npm cache clean or verify does not fix the problem.

Can't diagnose the problem further curently; deleting the local project, restoring from git and doing a fresh npm install fixes it.

thessalianpine avatar Dec 12 '17 11:12 thessalianpine

Same issue. Can't access bundled files when test deploying to AWS with ng serve(shown below), or when accessing index.html from an ng build locally. However, npm start works perfectly locally, and the app runs with no issues.

ng serve --disable-host-check=true --host 0.0.0.0 --base-href /test

node 6.11.0 npm 5.5.1 Windows 10 Pro

"@angular/cdk": "5.0.0", "@angular/common": "^5.0.0", "@angular/compiler": "^5.0.0", "@angular/core": "^5.0.0",

"@angular/cli": "^1.6.0", "@angular/compiler-cli": "^5.0.0", "@angular/language-service": "^5.0.0",

gpickney avatar Dec 12 '17 16:12 gpickney

I was having the same issue after running ng build. For some reason, my base-href in index.html wasn't being updated to the value specified in my package.json file.

After manually updating it, the errors went away. I ended up just running the full ng build --prod --bh command

ravenlark avatar Dec 12 '17 18:12 ravenlark

One way script.bundle.js is not generated is if there is a typescript error, but the compile is still successful. I was able to reproduce it this way:

  1. ng new repro-app
  2. npm install --save jquery
  3. Add to .angular-cli.json:
      "scripts": [
        "../node_modules/jquery/dist/jquery.min.js"
      ],
  1. Add to AppComponent.ts:
  foo(error) {
    if (error instanceof Response) {
      let errMsg = error.error;
    }    
  }
  1. ng serve
  2. Complile will error with: webpack: Failed to compile.
  3. Add colon to end of line in AppComonent.ts, and re-save the file:
  let errMsg = error.error;;
  1. Comile will pass with: webpack: Compiled successfully.
  2. Error in the browser: 404 script.bundle.js not found

Using:

Angular CLI: 1.6.0
Node: 6.9.1
OS: win32 x64
Angular: 5.1.0

dmacfarlane avatar Dec 13 '17 16:12 dmacfarlane

Same here.

richfergus avatar Dec 13 '17 21:12 richfergus

Same error here

[EDIT] with ng serve --aot it's working

Angular CLI: 1.6.0
Node: 8.3.0
OS: darwin x64
Angular: 5.1.1
... animations, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, router

@angular/cli: 1.6.0
@angular-devkit/build-optimizer: 0.0.35
@angular-devkit/core: 0.0.22
@angular-devkit/schematics: 0.0.41
@ngtools/json-schema: 1.1.0
@ngtools/webpack: 1.9.0
@schematics/angular: 0.1.10
@schematics/schematics: 0.0.10
typescript: 2.4.2
webpack: 3.10.0

miff avatar Dec 14 '17 00:12 miff

First time trying to build an angular 5 application after having created one with angular 4 (both with angular-cli), and ran into the same issue.

Skipping --aot nor clearing npm cache nor updating node and npm to the latest versions solved my issue. My conclusion (supported by those noting that ng serve works while ng build doesn't) is that scripts.bundle.js is not needed on an initial build since the latest angular-cli, and thus is not created (as it also is not referenced in index.html in the dist folder after ng build).

The initial error (scripts.bundle.js net::ERR_ABORTED), that led me to this github issue page, occured on our server version where we have an index.html file already in place (wíth a reference to scripts.bundle.js by default as it never threw an issue with angular 4 / older version of angular-cli as that file was always included). So, removing the reference to scripts.bundle.js in the index.html file eventually solved it for me. (woohoow)

Now I'm only hoping that scripts.bundle.js wíll get created the moment it becomes of any value. :) But for now I got ng build to work on the server, just like ng serve worked locally.

Hope this can help others and that this makes sense to @filipesilva as well.

yorickp avatar Dec 14 '17 16:12 yorickp

npm cache verify saves the day :)

prasanthnv avatar Jan 19 '18 07:01 prasanthnv

I was facing the same issue, solved by changing base href="/" to "./" in index.html after build

jcuervas avatar Feb 03 '18 00:02 jcuervas

If you are uploading this to github pages: change "/" to "./" in any sheet or script tags in your built index.html and upload it like that

sebamed avatar Feb 06 '18 22:02 sebamed

confirm this was fixed after upgrading the CLI from 1.5.0 to 1.6.7

EmanuelCarneiro avatar Feb 07 '18 13:02 EmanuelCarneiro

Closing as resolved with the 1.6.7+. If the issue persists, please open a new issue detailing the problem.

clydin avatar Feb 07 '18 14:02 clydin

I used both npm cache verify and npm cache clean and even restart angular cli. Sometime it works, sometimes it doesn't work. It's so weird to me. I still don't know what exactly reason here. Any beyond workarounds for this issue?

duyngha avatar Feb 23 '18 01:02 duyngha

npm cache verify work for me.

Thanks

Vaibhav2812 avatar Apr 25 '18 11:04 Vaibhav2812

This issue has been automatically locked due to inactivity. Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.