我做了一个新的安装角4项目,我试图加载故宫包steem
在这样的:不能导入角4 NPM包,需要一个JSON文件
app.component .TS
import {Component, OnInit} from '@angular/core';
import * as steem from 'steem';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent implements OnInit {
title = 'app works!';
ngOnInit() {
steem.api.getAccounts(['test', 'test2'], function(err, response){
console.log(err, response);
});
}
}
然而,出现以下错误:
Failed to compile.
./~/steem/lib/api/index.js
Module not found: Error: Can't resolve './methods' in '/Users/Stephan/Dev/kanzeon/node_modules/steem/lib/api'
@ ./~/steem/lib/api/index.js 17:15-35
@ ./~/steem/lib/index.js
@ ./src/app/app.component.ts
@ ./src/app/app.module.ts
@ ./src/main.ts
@ multi webpack-dev-server/client?http://localhost:4200 ./src/main.ts
在我看来,这是造成的,因为在./methods
,它解决不了是一个JSON文件。 Angular-cli的webpack配置包含一个json加载器(并且我已经安装了json-loader
npm包),但在加载器中存在线路exclude: 'node_modules'
。我真的不想重写我自己的angular-cli的webpack配置(有一个很好的理由,为什么他们隐藏它的实现,它的配置非常有效),但这确实对我的应用程序造成了问题。
有没有办法确保我可以包含steem
npm包并让它加载其json文件而不覆盖webpack配置?
...并由steemit团队解决,他们只是用js文件替换了json https://github.com/steemit/steem-js/issues/210#issuecomment-315809234 –