简体   繁体   English

SystemJS无法从node_modules加载模块

[英]SystemJS not loading modules from node_modules

I'm using SystemJS to load a simple JavaScript file: 我正在使用SystemJS加载一个简单的JavaScript文件:

define("main", ["require", "exports", "jquery"], function (require, exports, $) {
    "use strict";
    exports.__esModule = true;
    console.log($(document).html());
});

I'm loading it like so: 我像这样加载它:

<script>require("systemjs")</script>
<script>
    SystemJS.import('./dist/app.js').then(null, console.error.bind(console));
</script>

But I am getting an error when I run it in electron: 但是在电子环境中运行时出现错误:

GET file:///D:/Projects/myapp/app/jquery net::ERR_FILE_NOT_FOUND

Why is SystemJS not looking for jquery in node_modules like any other sane javascript loader? 为什么node_modules不像其他任何明智的javascript加载器那样在node_modules寻找jquery? How do I get it to look there? 我如何才能看到它?

It turns out the problem was that my compiler hadn't detected the changes yet so the generated file contained code for a different module. 事实证明,问题是我的编译器尚未检测到更改,因此生成的文件包含用于另一个模块的代码。 It still isn't working the way I want it too, but at least it's not erroring :/ 它仍然没有按照我想要的方式工作,但至少没有出错:/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM