用电子和Systemjs导入节点模块
我只是想知道是否有可能让systemjs使用require(“remote”)。require(“nodemodule”),如果系统js无法在自己的registry中find该模块?
我认为像这种机制的东西已经在使用电子与打字稿和commonjs模块工作…
有人已经解决了这个问题吗?
最后一段时间后,我find了一个工作解决scheme
var node_modules = ["child_process","fs"]; var fetch = System.fetch; window.remote=require("remote"); System.fetch = function () { var promise= fetch.apply(System,arguments); return promise.then(function (js) { for(var m of node_modules){ var requireExpression = 'require("'+m+'");'; var remoteRequire = 'remote.require("'+m+'");' js=js.replace(requireExpression,remoteRequire); } return js; }); } System.import("aurelia-bootstrapper");
只需将所有导入的node_modules添加到数组中,事情就没有问题
- 从Typescript类定义ExpressJS路由
- TypeScript readline.createInterface引发exception
- 有没有一种方法来要求JavaScript文件内的打字稿文件?
- 在打字稿中访问Nodejsstream的highWaterMark属性给出:“Property'_readableState'不存在”错误
- Typescript无法findExpress模块
- 无法在同一个TypeScript项目中使用requireJS和Node的Require
- (打字稿)属性“窗口”不存在types“全球”
- 我如何使用TypeScript的命令(npm)?
- 带有节点的内存中的Transpile TypeScript