需要一个合适的加载器来处理这种文件类型。 | * @type {import('../../ipfs/src/core/components/add-all').AddAll<import(‘.’).HttpOptions>}
Need an appropriate loader to handle this file type. | * @type {import(‘../../ipfs/src/core/components/add-all’).AddAll<import(‘.’).HttpOptions>}
我从 GitHub 下载了源代码并尝试 运行 它。
它 运行 但随后出现了“ipfs-api” 的问题,所以我安装了最新版本的“iphs-http-client” 现在它弹出了很多与 [=15= 有关的错误]
如果不能告诉我原因,请告诉我这是否可以解决,我是新手
error in ./node_modules/ipfs-http-client/src/add-all.js
Module parse failed: C:\Users\lione\Sample\Document-verification-on-Blockchain\node_modules\ipfs-http-client\src\add-all.js Unexpected token (16:17)
You may need an appropriate loader to handle this file type.
| * @type {import('../../ipfs/src/core/components/add-all').AddAll<import('.').HttpOptions>}
| */
| async function * addAll (input, options = {}) {
| const progressFn = options.progress
|
@ ./node_modules/ipfs-http-client/src/index.js 32:12-32
@ ./ethereum/ipfs.js
@ ./pages/Org/show.js?entry
@ multi ./pages/Org/show.js?entry
this is the error log
添加-all.js
'use strict'
const CID = require('cids')
const toCamel = require('./lib/object-to-camel')
const configure = require('./lib/configure')
const multipartRequest = require('./lib/multipart-request')
const toUrlSearchParams = require('./lib/to-url-search-params')
const anySignal = require('any-signal')
const AbortController = require('abort-controller').default
module.exports = configure((api) => {
// eslint-disable-next-line valid-jsdoc
/**
* @type {import('../../ipfs/src/core/components/add-all').AddAll<import('.').HttpOptions>}
*/
async function * addAll (input, options = {}) {
const progressFn = options.progress
// allow aborting requests on body errors
const controller = new AbortController()
const signal = anySignal([controller.signal, options.signal])
const res = await api.post('add', {
searchParams: toUrlSearchParams({
'stream-channels': true,
...options,
progress: Boolean(progressFn)
}),
timeout: options.timeout,
signal,
...(
await multipartRequest(input, controller, options.headers)
)
})
for await (let file of res.ndjson()) {
file = toCamel(file)
if (file.hash !== undefined) {
yield toCoreInterface(file)
} else if (progressFn) {
progressFn(file.bytes || 0)
}
}
}
return addAll
})
/**
* @typedef {import('../../ipfs/src/core/components/add-all').UnixFSEntry} UnixFSEntry
*/
/**
* @returns {UnixFSEntry}
*/
function toCoreInterface ({ name, hash, size, mode, mtime, mtimeNsecs }) {
const output = {
path: name,
cid: new CID(hash),
size: parseInt(size)
}
if (mode != null) {
output.mode = parseInt(mode, 8)
}
if (mtime != null) {
output.mtime = {
secs: mtime,
nsecs: mtimeNsecs || 0
}
}
// @ts-ignore
return output
}
index.js
'use strict'
/* eslint-env browser */
const CID = require('cids')
const multiaddr = require('multiaddr')
const multibase = require('multibase')
const multicodec = require('multicodec')
const multihash = require('multihashes')
const globSource = require('ipfs-utils/src/files/glob-source')
const urlSource = require('ipfs-utils/src/files/url-source')
/**
* @typedef { import("./lib/core").ClientOptions } ClientOptions
*/
/**
* @typedef {object} HttpOptions
* @property {Headers | Record<string, string>} [headers] - An object or [Headers](https://developer.mozilla.org/en-US/docs/Web/API/Headers) instance that can be used to set custom HTTP headers. Note that this option can also be [configured globally](#custom-headers) via the constructor options.
* @property {URLSearchParams | Record<string, string>} [searchParams] - An object or [`URLSearchParams`](https://developer.mozilla.org/en-US/docs/Web/API/URLSearchParams) instance that can be used to add additional query parameters to the query string sent with each request.
* @property {object} [ipld]
* @property {any[]} [ipld.formats] - An array of additional [IPLD formats](https://github.com/ipld/interface-ipld-format) to support
* @property {(format: string) => Promise<any>} [ipld.loadFormat] - an async function that takes the name of an [IPLD format](https://github.com/ipld/interface-ipld-format) as a string and should return the implementation of that codec
*/
// eslint-disable-next-line valid-jsdoc
/**
* @param {ClientOptions} options
*/
function ipfsClient (options = {}) {
return {
add: require('./add')(options),
addAll: require('./add-all')(options),
bitswap: require('./bitswap')(options),
block: require('./block')(options),
bootstrap: require('./bootstrap')(options),
cat: require('./cat')(options),
commands: require('./commands')(options),
config: require('./config')(options),
dag: require('./dag')(options),
dht: require('./dht')(options),
diag: require('./diag')(options),
dns: require('./dns')(options),
files: require('./files')(options),
get: require('./get')(options),
getEndpointConfig: require('./get-endpoint-config')(options),
id: require('./id')(options),
key: require('./key')(options),
log: require('./log')(options),
ls: require('./ls')(options),
mount: require('./mount')(options),
name: require('./name')(options),
object: require('./object')(options),
pin: require('./pin')(options),
ping: require('./ping')(options),
pubsub: require('./pubsub')(options),
refs: require('./refs')(options),
repo: require('./repo')(options),
resolve: require('./resolve')(options),
stats: require('./stats')(options),
stop: require('./stop')(options),
shutdown: require('./stop')(options),
swarm: require('./swarm')(options),
version: require('./version')(options)
}
}
Object.assign(ipfsClient, { CID, multiaddr, multibase, multicodec, multihash, globSource, urlSource })
module.exports = ipfsClient
看起来您正在通过 webpack 使用 babel 来转换源代码,但它无法解析异步生成器函数语法。您可能需要添加插件或以其他方式修复您的配置。
我从 GitHub 下载了源代码并尝试 运行 它。 它 运行 但随后出现了“ipfs-api” 的问题,所以我安装了最新版本的“iphs-http-client” 现在它弹出了很多与 [=15= 有关的错误]
如果不能告诉我原因,请告诉我这是否可以解决,我是新手
error in ./node_modules/ipfs-http-client/src/add-all.js
Module parse failed: C:\Users\lione\Sample\Document-verification-on-Blockchain\node_modules\ipfs-http-client\src\add-all.js Unexpected token (16:17)
You may need an appropriate loader to handle this file type.
| * @type {import('../../ipfs/src/core/components/add-all').AddAll<import('.').HttpOptions>}
| */
| async function * addAll (input, options = {}) {
| const progressFn = options.progress
|
@ ./node_modules/ipfs-http-client/src/index.js 32:12-32
@ ./ethereum/ipfs.js
@ ./pages/Org/show.js?entry
@ multi ./pages/Org/show.js?entry
this is the error log
添加-all.js
'use strict'
const CID = require('cids')
const toCamel = require('./lib/object-to-camel')
const configure = require('./lib/configure')
const multipartRequest = require('./lib/multipart-request')
const toUrlSearchParams = require('./lib/to-url-search-params')
const anySignal = require('any-signal')
const AbortController = require('abort-controller').default
module.exports = configure((api) => {
// eslint-disable-next-line valid-jsdoc
/**
* @type {import('../../ipfs/src/core/components/add-all').AddAll<import('.').HttpOptions>}
*/
async function * addAll (input, options = {}) {
const progressFn = options.progress
// allow aborting requests on body errors
const controller = new AbortController()
const signal = anySignal([controller.signal, options.signal])
const res = await api.post('add', {
searchParams: toUrlSearchParams({
'stream-channels': true,
...options,
progress: Boolean(progressFn)
}),
timeout: options.timeout,
signal,
...(
await multipartRequest(input, controller, options.headers)
)
})
for await (let file of res.ndjson()) {
file = toCamel(file)
if (file.hash !== undefined) {
yield toCoreInterface(file)
} else if (progressFn) {
progressFn(file.bytes || 0)
}
}
}
return addAll
})
/**
* @typedef {import('../../ipfs/src/core/components/add-all').UnixFSEntry} UnixFSEntry
*/
/**
* @returns {UnixFSEntry}
*/
function toCoreInterface ({ name, hash, size, mode, mtime, mtimeNsecs }) {
const output = {
path: name,
cid: new CID(hash),
size: parseInt(size)
}
if (mode != null) {
output.mode = parseInt(mode, 8)
}
if (mtime != null) {
output.mtime = {
secs: mtime,
nsecs: mtimeNsecs || 0
}
}
// @ts-ignore
return output
}
index.js
'use strict'
/* eslint-env browser */
const CID = require('cids')
const multiaddr = require('multiaddr')
const multibase = require('multibase')
const multicodec = require('multicodec')
const multihash = require('multihashes')
const globSource = require('ipfs-utils/src/files/glob-source')
const urlSource = require('ipfs-utils/src/files/url-source')
/**
* @typedef { import("./lib/core").ClientOptions } ClientOptions
*/
/**
* @typedef {object} HttpOptions
* @property {Headers | Record<string, string>} [headers] - An object or [Headers](https://developer.mozilla.org/en-US/docs/Web/API/Headers) instance that can be used to set custom HTTP headers. Note that this option can also be [configured globally](#custom-headers) via the constructor options.
* @property {URLSearchParams | Record<string, string>} [searchParams] - An object or [`URLSearchParams`](https://developer.mozilla.org/en-US/docs/Web/API/URLSearchParams) instance that can be used to add additional query parameters to the query string sent with each request.
* @property {object} [ipld]
* @property {any[]} [ipld.formats] - An array of additional [IPLD formats](https://github.com/ipld/interface-ipld-format) to support
* @property {(format: string) => Promise<any>} [ipld.loadFormat] - an async function that takes the name of an [IPLD format](https://github.com/ipld/interface-ipld-format) as a string and should return the implementation of that codec
*/
// eslint-disable-next-line valid-jsdoc
/**
* @param {ClientOptions} options
*/
function ipfsClient (options = {}) {
return {
add: require('./add')(options),
addAll: require('./add-all')(options),
bitswap: require('./bitswap')(options),
block: require('./block')(options),
bootstrap: require('./bootstrap')(options),
cat: require('./cat')(options),
commands: require('./commands')(options),
config: require('./config')(options),
dag: require('./dag')(options),
dht: require('./dht')(options),
diag: require('./diag')(options),
dns: require('./dns')(options),
files: require('./files')(options),
get: require('./get')(options),
getEndpointConfig: require('./get-endpoint-config')(options),
id: require('./id')(options),
key: require('./key')(options),
log: require('./log')(options),
ls: require('./ls')(options),
mount: require('./mount')(options),
name: require('./name')(options),
object: require('./object')(options),
pin: require('./pin')(options),
ping: require('./ping')(options),
pubsub: require('./pubsub')(options),
refs: require('./refs')(options),
repo: require('./repo')(options),
resolve: require('./resolve')(options),
stats: require('./stats')(options),
stop: require('./stop')(options),
shutdown: require('./stop')(options),
swarm: require('./swarm')(options),
version: require('./version')(options)
}
}
Object.assign(ipfsClient, { CID, multiaddr, multibase, multicodec, multihash, globSource, urlSource })
module.exports = ipfsClient
看起来您正在通过 webpack 使用 babel 来转换源代码,但它无法解析异步生成器函数语法。您可能需要添加插件或以其他方式修复您的配置。