node-binance-api: problem with dependencies

Short Description: build error when using package

Platform:

  • ubuntu 16.04

node version:

  • v10.1.0 and v8.11.2

npm version:

  • 5.10.0 and 5.6.0

Long descrption After each assembly produces an error:

These dependencies were not found:

* child_process in ./node_modules/shelljs/src/exec.js
* dgram in ./node_modules/native-dns-cache/lookup.js, ./node_modules/native-dns/lib/server.js and 1 other
* fs in ./node_modules/native-dns/lib/platform.js, ./node_modules/node-binance-api/node-binance-api.js and 20 others

To install them, you can run: npm install --save child_process dgram fs

code

const binance = require('node-binance-api');

set dependencies several times, tried different versions of nodejs, also tried to use yarn

thank you

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 16 (4 by maintainers)

Commits related to this issue

Most upvoted comments

I think the missing dependencies are due to the fact that vue is trying to call node-binance-api library on the browser-end, which doesn’t have node libraries such as fs, dgram etc, because they are typically server-side libraries… The solution is simply trying to keep all the node-binance-api calls only on the server side. I use nuxtjs framework with server api middleware. All node-binance-api calls are made via axios to the server api.

I think I fixed it by adding

node: {
    fs: "empty",
    dgram: "empty"
  }

to module.exports in ./build/webpack.dev.conf.js .

I should confess, I have no idea why this worked.

June 2019, the problem still occurs and this is the solution. Thanks @pujitm

I think I fixed it by adding

node: {
    fs: "empty",
    dgram: "empty"
  }

to module.exports in ./build/webpack.dev.conf.js .

I should confess, I have no idea why this worked.

Found a fix here. I created vue.config.js, stored in the project root. This file is automatically loaded by @vue/cli-service if it’s present in your project root.

Complete file:

module.exports = {
    configureWebpack: {
        node: {
            fs: "empty",
            dgram: "empty",
            net: 'empty',
            tls: 'empty',
            dns: 'empty'
        }
    }
}

I am also having this issue. Specifically, I’m use Vue and am getting:

This dependency was not found: * dns in ./node_modules/socks-proxy-agent/index.js

@joaquinnunez any ideas on a fix here in vuejs? Importing the “dns” module then leads to another issue of failing to find “net”…