在Angular2中从localhost运行插件typescript库

在Angular2中从localhost运行插件typescript库,angular,typescript,Angular,Typescript,每次我运行angular2项目时,都会从unpkg.com/plugin-typescript/lib/plugin.js加载大量文件和“ts”库。我想摆脱从另一台服务器加载的文件。我已经在本地安装了,但是当我像其他人一样给出本地路径时,我得到了错误“响应状态为404(未找到)”,如下所示:  加载资源失败:服务器响应状态为404(未找到) 加载资源失败:服务器响应状态为404(未找到) 加载资源失败:服务器响应状态为404(未找到) 加载资源失败:服务器响应状态为404(未找到) 加

每次我运行angular2项目时,都会从unpkg.com/plugin-typescript/lib/plugin.js加载大量文件和“ts”库。我想摆脱从另一台服务器加载的文件。我已经在本地安装了,但是当我像其他人一样给出本地路径时,我得到了错误“响应状态为404(未找到)”,如下所示: 

加载资源失败:服务器响应状态为404(未找到)

加载资源失败:服务器响应状态为404(未找到)

加载资源失败:服务器响应状态为404(未找到)

加载资源失败:服务器响应状态为404(未找到)

加载资源失败:服务器响应状态为404(未找到) html:18错误:错误:XHR错误(404未找到)加载(…)

我的systemjs.config.js是:

(职能(全球){

System.config({

})); })(本条)

还有我的Package.json

{

}


由于我是angular2和NPM的新手,我没有办法解决这个问题。任何建议或解决方案都值得高度赞赏。提前感谢

这是因为所有这些库都位于/node_modules/文件夹中,您的浏览器无法访问此文件夹。
将它们复制到应用程序静态内容所在的文件夹中(在我的例子中是wwwroot/js)。

这是因为所有这些库都位于/node_modules/文件夹中,而您的浏览器无法访问此文件夹。
将它们复制到应用程序静态内容所在的文件夹中(在我的例子中是wwwroot/js)。

我在IIS中托管我的Angular2应用程序,因此我向Web.Config添加了一个URL重写,将URL“/plugin-typescript/lib/logger/logger”重定向到“/plugin-typescript/lib/logger/logger.js”:



Steve

我在IIS中托管Angular2应用程序,因此我在Web.Config中添加了一个URL重写,将URL“/plugin-typescript/lib/logger/logger”重定向到“/plugin-typescript/lib/logger/logger.js”:


史蒂夫

transpiler: 'ts',

typescriptOptions: {

  tsconfig: true

},

meta: {
  'typescript': {
    "exports": "ts"
  }
},
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',
  'angular2-in-memory-web-api': 'npm:angular2-in-memory-web-api',
  'ts':                         'npm:plugin-typescript/lib/plugin.js',
  //'ts':                       'https://unpkg.com/plugin-typescript/lib/plugin.js',
  'typescript':                 'npm:typescript/lib/typescript.js'

},
// packages tells the System loader how to load when no filename and/or no extension
packages: {
  app: {
    main: './main.ts',
    defaultExtension: 'ts'
  },
  rxjs: {
    defaultExtension: 'js'
  },
  'angular2-in-memory-web-api': {
    main: './index.js',
    defaultExtension: 'js'
  }
}
"name": "angular2-quickstart",

"version": "1.0.0",

"scripts": {

    "start": "tsc && concurrently \"npm run tsc:w\" \"npm run lite\" ",

    "lite": "lite-server",

    "postinstall": "typings install",

    "tsc": "tsc",

    "tsc:w": "tsc -w",

    "typings": "typings"

},

"license": "ISC",

"dependencies": {

    "@angular/common": "2.0.0-rc.6",

    "@angular/compiler": "2.0.0-rc.6",

    "@angular/compiler-cli": "0.6.0",

    "@angular/core": "2.0.0-rc.6",

    "@angular/forms": "2.0.0-rc.6",

    "@angular/http": "2.0.0-rc.6",

    "@angular/platform-browser": "2.0.0-rc.6",

    "@angular/platform-browser-dynamic": "2.0.0-rc.6",

    "@angular/router": "3.0.0-rc.2",

    "@angular/upgrade": "2.0.0-rc.6",

    "core-js": "^2.4.1",

    "reflect-metadata": "^0.1.3",

    "rxjs": "5.0.0-beta.11",

    "systemjs": "0.19.27",

    "zone.js": "^0.6.17",

    "angular2-in-memory-web-api": "0.0.18",

    "bootstrap": "^3.3.6"

},

"devDependencies": {

    "concurrently": "^2.2.0",

    "lite-server": "^2.2.2",

    "typescript": "^1.8.10",

    "typings": "^1.3.2"

}
  <system.webServer>
    <rewrite>
      <rules>
        <rule name="rewrite directories to .js" stopProcessing="true">
          <match url="(.*[^/])$" />
          <conditions>
            <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
            <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
            <add input="{REQUEST_FILENAME}" pattern="(.*?)\.[a-zA-Z]{1,4}$" negate="true" />
          </conditions>
          <action type="Rewrite" url="{R:1}.js" />
        </rule>
      </rules>
    </rewrite>
  </system.webServer>