我做了一個新的安裝角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 –