从Angular2应用程序链接到全局节点模块文件夹 [英] Link to global node modules folder from Angular2 app

查看:72
本文介绍了从Angular2应用程序链接到全局节点模块文件夹的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

由于Angular2 CLI在本地安装了125mb +的Node模块,我希望有一个集中的Node modules文件夹(使用npm update -g保存到C磁盘),而不是应用程序中包含的普通本地文件夹.文件夹.

I wish to have a centralised Node modules folder (using npm update -g to save to C disk) instead of the usual local folder which is contained in the app, due to Angular2 CLI installing 125mb+ worth of Node modules in the local folder.

因此在打字稿文件中,我们以前像这样导入了角核:

So in the typescript files we previously imported the angular core like so:

import { Component } from '@angular/core'; 

但是显然这是行不通的,是否可以在某个地方放置前缀或硬URL来告诉应用程序在全局文件夹中搜索模块?

But obviously this doesnt work, is it possible to put a prefix or hard URL somewhere to tell the app to search in the global folder for the modules?

推荐答案

修改 SystemJs 配置(通常是 systemjs.config.js 文件),因此它映射@angular 集中到 node_modules \ @angular 文件夹,而不是本地文件夹.

Modify SystemJs configuration (usually systemjs.config.js file), so it maps @angular to you centralized node_modules\@angular folder, instead of local one.

var  map = {
  'app' : 'app',
  '@angular' : 'C:/node_modules/@angular', // path to centralized repo
};

这篇关于从Angular2应用程序链接到全局节点模块文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆