Skip to content
This repository has been archived by the owner on Apr 16, 2021. It is now read-only.

UnhandledPromiseRejectionWarning: TypeError: skynet.uploadFile is not a function #47

Closed
ltfschoen opened this issue Aug 8, 2020 · 2 comments

Comments

@ltfschoen
Copy link

ltfschoen commented Aug 8, 2020

I've tried this with both Node.js 14.7.0 and v12.18.3 and both encounter the same error.
The README says to refer to the docs here https://github.com/NebulousLabs/nodejs-skynet#documentation
I added the dependency by running yarn add @nebulous/skynet https://github.com/NebulousLabs/nodejs-skynet#installing, but it appears to install an older version from ~5 months ago into node_modules/, even though the version shown in the package.json in node_modules/ is 1.0.1 (the same as in the latest 'master'). And the latest documentation uses the latest code from the 'master' branch instead of the latest code published at NPM.
If I even just try the example code at "Making Your First API Call" https://nebulouslabs.github.io/skynet-docs/?javascript#making-your-first-api-call, I get the following error:

(node:28545) UnhandledPromiseRejectionWarning: TypeError: skynet.uploadFile is not a function
    at /Users/ls/code/src/ltfschoen/skyhandler/scripts/skynetUpload.js:5:34
    at Object.<anonymous> (/Users/ls/code/src/ltfschoen/skyhandler/scripts/skynetUpload.js:10:3)
    at Module._compile (internal/modules/cjs/loader.js:1137:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1157:10)
    at Module.load (internal/modules/cjs/loader.js:985:32)
    at Function.Module._load (internal/modules/cjs/loader.js:878:14)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12)
    at internal/main/run_main_module.js:17:47

It appears to be because the code in the version that gets installed in node_modules/@nebulous/skynet on my local machine differs from the latest 'master' branch Github at https://github.com/NebulousLabs/nodejs-skynet (I assumed that was the version that's published to NPM, and I noticed that there aren't any official releases https://github.com/NebulousLabs/nodejs-skynet/releases).
If I inspect the code that gets installed to node_modules/@nebulous/skynet, it's clear that the error is caused because it's exporting capitalized UploadFile (I think triggered from this commit ~5 months ago 9e25320) instead of uploadFile that's used in the 'master' branch here https://github.com/NebulousLabs/nodejs-skynet/blob/master/src/upload.js#L20, and that code doesn't fallback to default values if the user doesn't provide all the necessary custom options as an argument to the uploadFile function (changes were made to improve this in the latest 'master'.

Also, I noticed in the latest 'master' branch that if the user doesn't provide a portalUrl property value as part of the customOptions parameter when calling uploadFile, it doesn't appear to fallback to a default value
https://github.com/NebulousLabs/nodejs-skynet/blob/master/src/upload.js#L28

I was able to get it to work if modified package.json to just install the latest version from the 'master' branch (instead of it being "@nebulous/skynet": "^1.0.1", when installed using yarn add @nebulous/skynet:

  "dependencies": {
    "@nebulous/skynet": "git://github.com/NebulousLabs/nodejs-skynet.git#master",
@mrcnski
Copy link
Contributor

mrcnski commented Aug 12, 2020

Thanks for raising this @ltfschoen. We haven't published a new version in a while. We'll try to do it later today -- apologies for the inconvenience.

@mrcnski
Copy link
Contributor

mrcnski commented Aug 12, 2020

We just published v1.1.0 which you can use.

@mrcnski mrcnski closed this as completed Aug 12, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants