【发布时间】:2017-11-01 17:26:38
【问题描述】:
我正在尝试使用simple-json-loader。我从 npm 安装它并编写以下函数:
onclickExport() {
var loader = require('simple-json-loader');
var json = loader.JSONLoader.loadFromFile('wwwroot/dist/data/files.json');
}
一切看起来很简单,但是当我在 webback 中运行构建时,我看到以下错误:
./~/simple-json-loader/index.js 中的错误 找不到模块:错误:无法解析 D:\GitRepo\Magazine\Magazine.Web\node_modules\simple-json-loader 中的模块“fs” @ ./~/simple-json-loader/index.js
Npm 包通过有效路径位于 node_modules 中。我在那里看到。 此外,在调试此功能时,我看到了类似的错误。 有什么想法为什么它不起作用?
【问题讨论】:
-
所以它是一个服务器端包,除非您使用类似
BrowserFS的东西,否则它不能在客户端(在浏览器中)工作。
标签: typescript webpack node-modules fs angular2-components