【问题标题】:How to add Node to an existing Angular 2 Typescript ASP.NET Core project如何将节点添加到现有的 Angular 2 Typescript ASP.NET Core 项目
【发布时间】:2017-05-03 20:22:00
【问题描述】:

我下载了一个 github 项目,我想在装有 Visual Studio 2015 Update 3 的机器上的 ASP.NET Core 项目中学习 TypeScript 和 Angular 2。

安装Microsoft.TypeScript.MSBuild 1.8.11 nuget 包后,我可以初步编译我的项目。但是,它失败,无法加载缺少 node_modules 包的 404 浏览器控制台错误。我的解决方案中不存在此文件夹。

我注意到systemjs.config.js 文件引用了 npm 和 node_modules。

/**
 * System configuration for Angular samples
 * Adjust as necessary for your application needs.
 */
(function (global) {
    System.config({
        paths: {
            // paths serve as alias
            'npm:': '/node_modules/',
            'tether': '/Scripts/lib/tether.js'
        },
        // map tells the System loader where to look for things
        map: {
            // our app is within the app folder
            app: '/Scripts',
            // 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',
            '@ng-bootstrap/ng-bootstrap': 'npm:/@ng-bootstrap/ng-bootstrap/bundles/ng-bootstrap.js',
            // other libraries
            'ng-lightning/ng-lightning': 'npm:ng-lightning/bundles/ng-lightning.umd.js',
            'primeng': 'npm:primeng',
            'lodash': 'npm:lodash',
            'rxjs': 'npm:rxjs'
        },
        // packages tells the System loader how to load when no filename and/or no extension
        packages: {
            app: {
                main: './main.js',
                defaultExtension: 'js'
            },
            primeng: {
                defaultExtension: 'js'
            },
            'ng-lightning': {
                defaultExtension: 'js'
            },
            lodash: {
                main: 'index.js',
                defaultExtension: 'js'
            },
            rxjs: {
                defaultExtension: 'js'
            }
        }
    });
})(this);

然而 github 项目没有 node、gulp、bower 或 npm 来让 node 工作。 我知道如果你创建一个默认的 Visual Studio 2015 ASP.NET Core 应用程序,它会默认添加工作节点,但是如何将它节点到原始 github 作者似乎没有签入的现有项目。

我的 tsconfig.json 文件也无法编译

{
  "compileOnSave": true,
  "compilerOptions": {
    "target": "es5",
    "module": "commonjs",
    "moduleResolution": "node",
    "sourceMap": true,
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "removeComments": false,
    "noImplicitAny": false,
    "typeRoots": [
      "node_modules/@types"
    ],
    "types": [
      "core-js"
    ]
  }
}

我明白了

构建:未知的编译器选项“类型”.VSTSC
构建:未知的编译器选项“typeRoots”。 VSTSC

【问题讨论】:

标签: angular visual-studio-2015 asp.net-core


【解决方案1】:

Node 应该全局安装在您的机器上以从 npm 安装依赖项。

安装节点时;运行npm install 在项目根文件夹中

【讨论】:

  • 我知道了,但还缺少其他东西。未创建 node_modules 导致节点包出现 404 错误
  • 是 package.json 在你运行“npm install”的文件夹中吗?
猜你喜欢
  • 2017-11-24
  • 2020-11-04
  • 2020-10-28
  • 1970-01-01
  • 2017-11-29
  • 2011-12-31
  • 2018-05-30
  • 1970-01-01
  • 2019-12-19
相关资源
最近更新 更多