bitcoinjs / tiny-secp256k1

A tiny secp256k1 native/JS wrapper
MIT License
86 stars 55 forks source link

no such file or directory node_modules/tiny-secp256k1/lib/secp256k1.wasm #116

Closed learntheropes closed 1 year ago

learntheropes commented 1 year ago

I'm using tiny-secp256k1 and bitcoinjs-lib with Nuxt 3 (Nitro server engine): https://nuxt.com/docs/guide/concepts/server-engine

"scripts": {
    "build": "nuxi build",
    "start": "node .output/server/index.mjs",
    "dev": "nuxi dev",
},
"dependencies": {
    "bip32": "^4.0.0",
    "bip39": "^3.1.0",
    "bitcoinjs-lib": "^6.1.0",
    "bitcoinjs-message": "^2.2.0",
    "tiny-secp256k1": "^2.2.2",
}
import { networks } from 'bitcoinjs-lib';
import BIP32Factory from 'bip32';
import * as ecc from 'tiny-secp256k1';
const bip32 = BIP32Factory.default(ecc);

With npm run dev works correctly, but with npm run build && npm run start I get:

ENOENT: no such file or directory, open '/home/giovanni/Documents/Dev/btcpay-booking/.output/server/node_modules/tiny-secp256k1/lib/secp256k1.wasm'

What could be the issue?

As of now, I resolved using https://github.com/bitcoinerlab/secp256k1

Is this the way to go?

junderw commented 1 year ago

This sounds like a Nuxt issue.

I just npm installed the latest version and the file is there:

$ ls node_modules/tiny-secp256k1/lib/
cjs                rand.js              wasm_loader.browser.d.ts
index.d.ts         secp256k1.wasm       wasm_loader.browser.js
index.js           validate.d.ts        wasm_loader.d.ts
rand.browser.d.ts  validate_error.d.ts  wasm_loader.js
rand.browser.js    validate_error.js    wasm_path.d.ts
rand.d.ts          validate.js          wasm_path.js
junderw commented 1 year ago

Is this the way to go?

I have looked over bitcoinerlab's library and it seems fine. If that works, it should be fine.

Demiduska commented 1 year ago

Hello, did you solve the problem?

learntheropes commented 1 year ago

@Demiduska I'm using https://github.com/bitcoinerlab/secp256k1 package

Demiduska commented 1 year ago

Unfortunately, I have internal libraries, which use tiny-secp256k1. Did you use Vercel to deploy the app or other hosting?

learntheropes commented 1 year ago

Digital Ocean. On Vercel I always face the problem of slow app when I have big server functions due to cold start, I think.

Demiduska commented 1 year ago

https://github.com/bitcoinerlab/secp256k1 package

Thank you, I rewrote the code for https://github.com/bitcoinerlab/secp256k1 package and it starts working.

Sentini14 commented 2 weeks ago

Which one is the best