denoland / deno

A modern runtime for JavaScript and TypeScript.
https://deno.com
MIT License
96.15k stars 5.31k forks source link

Could not find npm package 'tmp-promise' even though it exists #19634

Closed dogukanakkaya closed 1 month ago

dogukanakkaya commented 1 year ago

I have this below import in my code:

import Bundlr from 'npm:@bundlr-network/client'

error: Could not resolve 'tmp-promise' from 'deno/npm/registry.npmjs.org/arbundles/0.9.8/build/node/esm/src/file/bundleData.js'.

Caused by: Could not find npm package 'tmp-promise' referenced by 'arbundles@0.9.8'.

But package exists here: https://www.npmjs.com/package/tmp-promise

bartlomieju commented 1 year ago

@dsherret any idea what causes this problem?

dogukanakkaya commented 1 year ago

I tried to come back here to see the problem and tried a few things. Like manually installing that. After that I got few more similar errors on different modules:

error: Could not resolve 'multistream' from '.../deno/npm/registry.npmjs.org/arbundles/0.9.8/build/node/esm/src/file/FileBundle.js'.
Caused by:
    Could not find npm package 'multistream' referenced by 'arbundles@0.9.8'.

Could not resolve 'arweave-stream-tx' from '.../deno/npm/registry.npmjs.org/arbundles/0.9.8/build/node/esm/src/file/FileBundle.js'.
Caused by:
    Could not find npm package 'arweave-stream-tx' referenced by 'arbundles@0.9.8'.

Anyways I also installed those manually. But still even though server is running I got errors on called functions.

// ...
import Bundlr from 'npm:@bundlr-network/client'
import "npm:tmp-promise"
import "npm:multistream"
import "npm:arweave-stream-tx"
import jwk from "./my-jwk" assert { type: "json" };
import { Buffer } from "std/io/buffer.ts";

// ...

const bundlr = new Bundlr('http://node2.bundlr.network', 'arweave', jwk)

const { id: imageId } = await bundlr.upload(new Buffer(await file.arrayBuffer()), {
  tags: [{ name: 'Content-Type', value: file.type }]
})

// ...

First of all even initializing the Bundlr class is showing this log in the console:

bigint: Failed to load bindings, pure JS will be used (try npm run rebuild?)

And when this code runs I am having this below socket error:

error: Uncaught TypeError: socket.setTimeout is not a function
    at RedirectableRequest.destroyOnTimeout (.../deno/npm/registry.npmjs.org/follow-redirects/1.15.2/index.js:158:12)
    at RedirectableRequest.emit (ext:deno_node/_stream.mjs:1857:11)
    at ClientRequest.eventHandlers.<computed> (.../deno/npm/registry.npmjs.org/follow-redirects/1.15.2/index.js:14:24)
    at ClientRequest.emit (ext:deno_node/_stream.mjs:1857:11)
    at node:http:401:12
    at processTicksAndRejections (ext:deno_node/_next_tick.ts:25:11)
    at runNextTicks (ext:deno_node/_next_tick.ts:71:3)
    at eventLoopTick (ext:core/01_core.js:189:21)

@bartlomieju @dsherret

tobiasfuhlroth commented 1 year ago

Running into the exact same error when trying to use https://github.com/MoralisWeb3/Moralis-JS-SDK with Deno:

error: Uncaught TypeError: socket.setTimeout is not a function
    at RedirectableRequest.destroyOnTimeout (file:///Users/myuser/Library/Caches/deno/npm/registry.npmjs.org/follow-redirects/1.15.2/index.js:158:12)
    at RedirectableRequest.emit (ext:deno_node/_stream.mjs:1857:11)
    at HttpsClientRequest.eventHandlers.<computed> (file:///Users/myuser/Library/Caches/deno/npm/registry.npmjs.org/follow-redirects/1.15.2/index.js:14:24)
    at HttpsClientRequest.emit (ext:deno_node/_stream.mjs:1857:11)
    at node:http:401:12
    at processTicksAndRejections (ext:deno_node/_next_tick.ts:25:11)
    at runNextTicks (ext:deno_node/_next_tick.ts:71:3)
    at eventLoopTick (ext:core/01_core.js:189:21)

I think this is related to https://github.com/denoland/deno/issues/19535 as Moralis also uses Axios under the hood.

bartlomieju commented 1 year ago

@tobiasfuhlroth the socket.setTimeout seems to be a completely different issue than the one originally reported. I think it was indeed fixed in #19535 - do you see it when using Deno v1.36.3?

As for the original issue - we need to debug what's going on, I assume the problem is that it's not properly discovered as a dependency in one of the packages.

tobiasfuhlroth commented 1 year ago

@bartlomieju Yes, was using the newest version (v1.36.3) when this was occurring.

bartlomieju commented 1 year ago

@tobiasfuhlroth thanks for checking, would you mind opening a separate issue for this problem? That is an unexpected error at this point.

dogukanakkaya commented 1 year ago

Update here, still valid with latest version of Deno:

deno 1.37.1 (release, aarch64-apple-darwin)
v8 11.8.172.3
typescript 5.2.2
marvinhagemeister commented 1 month ago

I cannot reproduce the described error anymore. The tmp-promise package is installed correctly.