使用 nodejs 和 npm 以 ASp.net 核心 1 在 angular2 中导入脚本的基础知识

Basics of importing scripts in angular2 using nodejs and npm with ASp.net Core 1

你好,我刚刚安装完 asp.net core1,所以在研究了很多之后,我开始接触 npm、bower 和 nodejs,我选择了 angular2。 现在我的问题是我从未使用过 gulp、grunt 等,尽管我知道它是如何工作的以及为什么要使用它。网上有很多使用 mvc6 设置 angular2 项目的说明,但没有解释 mvc6 的新功能。

无论如何,我现在不想让自己与 gulp/grunt 等混淆,所以我只是将文件从 node_modules 复制到我的脚本文件夹并为其提供路径,但它几乎适用于与angular。 例如。 import {anything} from 'angular2/core' 或来自 RXjs 等(此导入来自 node_modules),我必须在我复制所有文件的索引文件中提供路径。 但是当我尝试包含一些插件,如 ng2-select、ng2-bootstrap 或 toastr 等时,它无法正常工作,它会抛出错误。

我的问题是我是否需要将整个文件夹从 node_modules 复制到我的脚本文件夹,然后对其进行 linq 或者什么,它是如何工作的?

Do I need to copy whole folder from node_modules to my script folder and then link it or what, how does this work?

我在my blog post of what you should be doing in this situation. Ideally, you will use a gulpfile.js to orchestrate your desired file needs. For example, if you're looking for Angular2 it is rather simple. You create a gulpfile.js by adding a new item to your project. In that file you write some simple "tasks" that automate this move for you. You look in node_modules and move over anything that you need. For Angular2 I move over the following .js files (in this example中有一个例子):

var angularJs = [
    './node_modules/angular2/bundles/angular2.js',
    './node_modules/angular2/bundles/router.js',
    './node_modules/angular2/bundles/angular2-polyfills.js',
    './node_modules/angular2/bundles/http.js'
];

所以更直接地回答你的问题,不。您 不需要 复制整个文件夹 -- 只是您的应用程序需要的文件。