Cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Import dropbox-sdk to companion

ANSWERED

Hello everyone, i try to create an app which uses dropbox (my setup is vscode + cli). Therefore i want to use the dropbox sdk in the companion-part. I have install the npm-package successfully and import the dropbox-object like:

import { Dropbox } from 'Dropbox';

But when i try to build the app i got the following error: 

 

[error][companion] companion\index.ts:3,9 Error: 'Dropbox' is not exported by node_modules\Dropbox\es\index.es6.js
Details:
code: MISSING_EXPORT
url: https://rollupjs.org/guide/en#error-name-is-not-exported-by-module-
frame:
1: import { Dropbox } from 'Dropbox';
^

Because of the lack of documentation how to import a third party library i am not sure if there is more to do. The only thread i found was https://community.fitbit.com/t5/SDK-Development/My-example-of-using-third-party-ES-modules-lodash-re... and here is lookslike i have to copy the source to a special directory?! Hope someone can help, thx.

Best Answer
0 Votes
1 BEST ANSWER

Accepted Solutions

Ok,found a solution...if you go to the '...\node_modules\dropbox\package.json', remove the line

'"module": "es/index.es6.js"'.
It looks like it is a flag for bundler like rollup.js to determine which files are used (info-at-stackoverflow).
After that i could compile and get no error if i use the sdk. Hope this will save futher developers some time.

View best answer in original post

Best Answer
2 REPLIES 2

Ok after lot of trail and error coding, i am a step futher.

I changed the index.es6.js

//uncomment this
// export default { // Dropbox: Dropbox, // DropboxTeam: DropboxTeam // };
//and add this export { Dropbox as Dropbox }

I assume that the dropbox sdk and fitbit uses different version from rollup hence the error. Now i can compile and install the app. But i got the next error 😕

Companion: ReferenceError: babelHelpers is not defined
  ? at node_modules/dropbox/es/rpc-request.js:153,3
  ? at node_modules/dropbox/es/rpc-request.js:129,26

Maybe this time someone here has a clue for me to solve this issue?

Best Answer
0 Votes

Ok,found a solution...if you go to the '...\node_modules\dropbox\package.json', remove the line

'"module": "es/index.es6.js"'.
It looks like it is a flag for bundler like rollup.js to determine which files are used (info-at-stackoverflow).
After that i could compile and get no error if i use the sdk. Hope this will save futher developers some time.

Best Answer