BugHunterUK
BugHunterUK

Reputation: 8968

_util.default.promisify is not a function using Node 9.5

Node version:

node -v
v9.5.0

Code

import util from 'util'
import fingerprint from 'fingerprint2'
const Fingerprint = util.promisify(fingerprint.get)

The error I'm getting in the browser is:

Uncaught TypeError: _util.default.promisify is not a function

According to the docs it's supported. Any idea what is happening here?

I have also tried:

import { promisify } from 'util'

And

import util from 'util'
const { promisify } from util

... Same error.

Upvotes: 0

Views: 1486

Answers (2)

BugHunterUK
BugHunterUK

Reputation: 8968

Ok I managed to solve it. As this is a browser application it should have installed es6-promisify. Node's promisify will not work for obvious reasons. I should have realised that.

Upvotes: 4

Kit Isaev
Kit Isaev

Reputation: 700

import something from 'package';

is a shortand for

var something = require('package').default;

Use

import { promisify } from 'util';

instead.

Upvotes: 1

Related Questions