eosjs编译报错

lacs34 2018-12-30 01:33:42
我希望在网页上访问eos服务,根据eos官网的介绍,通过npm下载了eosjs,命令如下:
npm init -y
npm install eosjs@beta
结果发现eosjs是用typescript写的,如果要在前端使用,需要编译成js,因为发现eosjs里提供了webpack配置,所以准备通过webpack来编译typescript,命令如下:
npm install webpack webpack-cli typescript ts-loader
./node_modules/.bin/webpack --config ./webpack.debug.js
结果报错如下:

Hash: 15328fb466988ab8b5f9
Version: webpack 4.28.3
Time: 96ms
Built at: 12/30/2018 1:12:50 AM
Asset Size Chunks Chunk Names
eosjs-api-debug.js 8.85 KiB eosjs_api [emitted] eosjs_api
eosjs-jsonrpc-debug.js 10.9 KiB eosjs_jsonrpc [emitted] eosjs_jsonrpc
eosjs-jssig-debug.js 8.9 KiB eosjs_jssig [emitted] eosjs_jssig
Entrypoint eosjs_api = eosjs-api-debug.js
Entrypoint eosjs_jsonrpc = eosjs-jsonrpc-debug.js
Entrypoint eosjs_jssig = eosjs-jssig-debug.js
[./src/eosjs-api.ts] 310 bytes {eosjs_api} [built] [failed] [1 error]
[./src/eosjs-jsonrpc.ts] 277 bytes {eosjs_jsonrpc} [built] [failed] [1 error]
[./src/eosjs-jssig.ts] 354 bytes {eosjs_jssig} [built] [failed] [1 error]
[./src/eosjs-rpcerror.ts] 277 bytes {eosjs_jsonrpc} [built] [failed] [1 error]
[./src/rpc-web.ts] 122 bytes {eosjs_jsonrpc} [built]

ERROR in ./src/eosjs-jsonrpc.ts 11:24
Module parse failed: Unexpected token (11:24)
You may need an appropriate loader to handle this file type.
| import RpcError from "./eosjs-rpcerror";
|
> function arrayToHex(data: Uint8Array) {
| let result = "";
| for (const x of data) {
@ ./src/rpc-web.ts 1:0-38 4:0-40

ERROR in ./src/eosjs-jssig.ts 11:41
Module parse failed: Unexpected token (11:41)
You may need an appropriate loader to handle this file type.
|
| /** Signs transactions using in-process private keys */
> export default class JsSignatureProvider implements SignatureProvider {
| /** map public to private keys */
| public keys = new Map<string, string>();

ERROR in ./src/eosjs-api.ts 18:11
Module parse failed: Unexpected token (18:11)
You may need an appropriate loader to handle this file type.
| export default class Api {
| /** Issues RPC calls */
> public rpc: JsonRpc;
|
| /** Get subset of `availableKeys` needed to meet authorities in a `transac tion` */

ERROR in ./src/eosjs-rpcerror.ts 9:11
Module parse failed: Unexpected token (9:11)
You may need an appropriate loader to handle this file type.
| export default class RpcError extends Error {
| /** Detailed error information */
> public json: any;
|
| constructor(json: any) {
@ ./src/rpc-web.ts 2:0-40 4:0-40

看起来编译器根本不认typescript的代码,我是哪里配置错了么?
...全文
36 回复 打赏 收藏 转发到动态 举报
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复

791

社区成员

发帖
与我相关
我的任务
社区描述
区块链技术专区
区块链 技术论坛(原bbs)
社区管理员
  • 区块链技术
  • ccc908
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧