Im using this library to manage bitbucket api from nodejs.
I have received a message about a deprecated endpoint so I saw that library have released a new version (2).
So, I have uninstall bitbucket dependency and installed again to version 2.7.0
But now, Im getting an error like this:
let bitbucketAPI = new Bitbucket()
^
TypeError: Bitbucket is not a constructor
This is the change in package.json
- "bitbucket": "^1.15.1",
+ "bitbucket": "^2.7.0",
And this is my code:
let Bitbucket = require('bitbucket')
let bitbucketAPI = new Bitbucket()
I have deleted package-lock.json, node_modules/bitbucket folder, update dependencies with npm update but anything works..
Any idea?
The proper way to load this module is this:
const { Bitbucket } = require('bitbucket');
This is shown in the doc.
So, when you were just doing this:
let Bitbucket = require('bitbucket');
You were getting the module exports object, not the individual Bitbucket
property of that object. To further understand,
// get module exports object
const bitBucketModule = require('bitbucket');
// get Bitbucket property from the module exports object
const Bitbucket = bitBucketModule.Bitbucket;
And, the recommended method using object desctructuring:
const { Bitbucket } = require('bitbucket');
is just a shortcut way to do it with less code.