I have installed some js-libp2p packages on my Ethereum Blockchain-ipfs project and I wrote some codes like below.
const TCP = require('libp2p-tcp');
const MulticastDNS = require('libp2p-mdns');
const WS = require('libp2p-websockets');
const KadDHT = require('libp2p-kad-dht')
const mplex = require('libp2p-mplex');
const secio = require('libp2p-secio');
const libp2p = require('libp2p');
But the multicast-dns ,libp2p and libp2p-kad-dht packages is showing some error. Below shown is the error while importing libp2p package:
ERROR in ./~/libp2p/src/index.js
Module parse failed: /home/toshiba/Documents/sul/ipfs/CannesNew Full Codejan17/SportsFull CodeTESTRpc12may/SportsFull Code1april/node_modules/libp2p/src/index.js Unexpected token (120:8)
You may need an appropriate loader to handle this file type.
| this._dht = new DHT(this._switch, {
| datastore: this.datastore,
| …this._config.dht
| })
| }
@ ./app/backend/app.js 62:15-32
@ multi (webpack)-dev-server/client?http://localhost:8080 ./app/backend/app.js
My webpack.config.js code is shown below,
module: {
rules: [
{
test: /\.css$/,
use: [ 'style-loader', 'css-loader' ]
}
],
loaders: [
{ test: /\.json$/, use: 'json-loader' },
{
test: /\.js$/,
exclude: /(node_modules|bower_components)/,
loader: 'babel-loader',
query: {
presets: ['es2015'],
plugins: ['transform-runtime']
}
}
]
},
Environment
Npm version: 6.4.1
Node version: 8.12.0
Os:Ubuntu 18.04
webpack : 2.2.1
babel-loader: 6.2.10
Anyone please help me to resolve this issue.