首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >加载http://localhost:3000/angularfire2的angularfire2 XHR错误(404未找到)

加载http://localhost:3000/angularfire2的angularfire2 XHR错误(404未找到)
EN

Stack Overflow用户
提问于 2017-05-10 17:17:26
回答 2查看 544关注 0票数 0

在将angularfire2安装到我的项目时,我会收到以下控制台错误。我已经更新了节点,也迁移到了ng4,但问题仍然相同。我使用environment.ts添加了环境文件夹,该文件夹在快速启动设置中不存在,并添加了firebase配置详细信息。

在尝试将angularfire2安装到最新的角度快速启动时,我也会遇到同样的错误。

我试图根据Traceur not found : XHR (404 not found) error的建议进行故障排除,这是我能找到的最接近的问题,但没有成功。不确定这是否是类似的问题。

有人能告诉我出了什么问题以及如何解决吗?

谢谢

npm:3.8.9

节点:v6.10.3

打字稿版本:2.3.2

控制台错误

代码语言:javascript
复制
(index):18 Error: (SystemJS) XHR error (404 Not Found) loading http://localhost:3000/angularfire2
    Error: XHR error (404 Not Found) loading http://localhost:3000/angularfire2
        at XMLHttpRequest.wrapFn [as __zone_symbol___onreadystatechange] (http://localhost:3000/node_modules/zone.js/dist/zone.js:1032:39)
        at ZoneDelegate.invokeTask (http://localhost:3000/node_modules/zone.js/dist/zone.js:414:31)
        at Zone.runTask (http://localhost:3000/node_modules/zone.js/dist/zone.js:181:47)
        at XMLHttpRequest.ZoneTask.invoke (http://localhost:3000/node_modules/zone.js/dist/zone.js:476:38)
    Error loading http://localhost:3000/angularfire2 as "angularfire2" from http://localhost:3000/app/app.module.js
        at XMLHttpRequest.wrapFn [as __zone_symbol___onreadystatechange] (http://localhost:3000/node_modules/zone.js/dist/zone.js:1032:39)
        at ZoneDelegate.invokeTask (http://localhost:3000/node_modules/zone.js/dist/zone.js:414:31)
        at Zone.runTask (http://localhost:3000/node_modules/zone.js/dist/zone.js:181:47)
        at XMLHttpRequest.ZoneTask.invoke (http://localhost:3000/node_modules/zone.js/dist/zone.js:476:38)
    Error loading http://localhost:3000/angularfire2 as "angularfire2" from http://localhost:3000/app/app.module.js

app.module.ts

代码语言:javascript
复制
import { NgModule }      from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';

import { AppComponent }  from './app.component';
import { AngularFireModule } from 'angularfire2';
import { AngularFireDatabaseModule } from 'angularfire2/database';
import { AngularFireAuthModule } from 'angularfire2/auth';
import { environment } from '../environments/environment';
// import * as firebase from 'firebase';

@NgModule({
  imports:      [
    BrowserModule,
    AngularFireModule.initializeApp(environment.firebase), // imports firebase/app needed for everything
    AngularFireDatabaseModule, // imports firebase/database, only needed for database features
    AngularFireAuthModule, // imports firebase/auth, only needed for auth features
 ],
  declarations: [ AppComponent ],
  bootstrap:    [ AppComponent ]
})
export class AppModule { }

package.json

代码语言:javascript
复制
{
  "name": "angular-quickstart",
  "version": "1.0.0",
  "description": "QuickStart package.json from the documentation, supplemented with testing support",
  "scripts": {
    "build": "tsc -p src/",
    "build:watch": "tsc -p src/ -w",
    "build:e2e": "tsc -p e2e/",
    "serve": "lite-server -c=bs-config.json",
    "serve:e2e": "lite-server -c=bs-config.e2e.json",
    "prestart": "npm run build",
    "start": "concurrently \"npm run build:watch\" \"npm run serve\"",
    "pree2e": "npm run build:e2e",
    "e2e": "concurrently \"npm run serve:e2e\" \"npm run protractor\" --kill-others --success first",
    "preprotractor": "webdriver-manager update",
    "protractor": "protractor protractor.config.js",
    "pretest": "npm run build",
    "test": "concurrently \"npm run build:watch\" \"karma start karma.conf.js\"",
    "pretest:once": "npm run build",
    "test:once": "karma start karma.conf.js --single-run",
    "lint": "tslint ./src/**/*.ts -t verbose"
  },
  "keywords": [],
  "author": "",
  "license": "MIT",
  "dependencies": {
    "@angular/common": "~4.0.0",
    "@angular/compiler": "~4.0.0",
    "@angular/core": "~4.0.0",
    "@angular/forms": "~4.0.0",
    "@angular/http": "~4.0.0",
    "@angular/platform-browser": "~4.0.0",
    "@angular/platform-browser-dynamic": "~4.0.0",
    "@angular/router": "~4.0.0",
    "angular-in-memory-web-api": "~0.3.0",
    "angularfire2": "^4.0.0-rc.0",
    "core-js": "^2.4.1",
    "firebase": "^3.9.0",
    "rxjs": "5.0.1",
    "systemjs": "0.19.40",
    "zone.js": "^0.8.4"
  },
  "devDependencies": {
    "@angular/cli": "^1.0.2",
    "@types/jasmine": "2.5.36",
    "@types/node": "^6.0.46",
    "canonical-path": "0.0.2",
    "concurrently": "^3.2.0",
    "jasmine-core": "~2.4.1",
    "karma": "^1.3.0",
    "karma-chrome-launcher": "^2.0.0",
    "karma-cli": "^1.0.1",
    "karma-jasmine": "^1.0.2",
    "karma-jasmine-html-reporter": "^0.2.2",
    "lite-server": "^2.2.2",
    "lodash": "^4.16.4",
    "protractor": "~4.0.14",
    "rimraf": "^2.5.4",
    "tslint": "^3.15.1",
    "typescript": "~2.1.0"
  },
  "repository": {}
}

systems.config.js

代码语言:javascript
复制
/**
 * System configuration for Angular samples
 * Adjust as necessary for your application needs.
 */
(function (global) {
  System.config({
    paths: {
      // paths serve as alias
      'npm:': 'node_modules/'
    },
    // map tells the System loader where to look for things
    map: {
      // our app is within the app folder
      'app': 'app',

      // angular bundles
      '@angular/core': 'npm:@angular/core/bundles/core.umd.js',
      '@angular/common': 'npm:@angular/common/bundles/common.umd.js',
      '@angular/compiler': 'npm:@angular/compiler/bundles/compiler.umd.js',
      '@angular/platform-browser': 'npm:@angular/platform-browser/bundles/platform-browser.umd.js',
      '@angular/platform-browser-dynamic': 'npm:@angular/platform-browser-dynamic/bundles/platform-browser-dynamic.umd.js',
      '@angular/http': 'npm:@angular/http/bundles/http.umd.js',
      '@angular/router': 'npm:@angular/router/bundles/router.umd.js',
      '@angular/forms': 'npm:@angular/forms/bundles/forms.umd.js',

      // other libraries
      'rxjs':                      'npm:rxjs',
      'angular-in-memory-web-api': 'npm:angular-in-memory-web-api/bundles/in-memory-web-api.umd.js'
    },
    // packages tells the System loader how to load when no filename and/or no extension
    packages: {
      app: {
        defaultExtension: 'js',
        meta: {
          './*.js': {
            loader: 'systemjs-angular-loader.js'
          }
        }
      },
      rxjs: {
        defaultExtension: 'js'
      }
    }
  });
})(this);

尝试安装angularfire2的全角度快速启动文件可以找到这里

EN

回答 2

Stack Overflow用户

发布于 2017-05-23 11:03:36

在“// other libraries in system.config.js路径”下添加模块目录中的angularfire2主脚本。

票数 0
EN

Stack Overflow用户

发布于 2017-05-31 12:23:55

我最终得到的解决方案是使用角火&角钢的安装和安装创建一个全新的项目。然后,我迁移了我的应用程序文件,从我已经建立的项目,从角的快速启动。

我发现这个博客对任何试图将angularfire2添加到使用角快速启动的项目中的人都是有帮助的。这最初帮助解决了404错误,但我遇到了更多的跟踪错误,因此最终选择了上述解决方案。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/43898943

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档