Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ReferenceError: window is not defined #4060

Open
dcmwong opened this issue Nov 12, 2023 · 2 comments
Open

ReferenceError: window is not defined #4060

dcmwong opened this issue Nov 12, 2023 · 2 comments
Labels

Comments

@dcmwong
Copy link

dcmwong commented Nov 12, 2023

Environment Details

  • OS: MacOS
  • Node Version: 18.18.2
  • BitGoJS Version: 1.24
  • BitGo Environment: Test

Expected Behavior

Create wallet and return success

Current Behavior

I get this error

⨯ node_modules/secrets.js-grempe/secrets.js (296:15) @ getRNG
 ⨯ ReferenceError: window is not defined
    at getRNG (webpack-internal:///(rsc)/./node_modules/secrets.js-grempe/secrets.js:245:16)
    at Object.setRNG (webpack-internal:///(rsc)/./node_modules/secrets.js-grempe/secrets.js:477:23)
    at Object.init (webpack-internal:///(rsc)/./node_modules/secrets.js-grempe/secrets.js:376:22)
    at eval (webpack-internal:///(rsc)/./node_modules/secrets.js-grempe/secrets.js:635:13)
    at Object.eval (webpack-internal:///(rsc)/./node_modules/secrets.js-grempe/secrets.js:18:72)
    at eval (webpack-internal:///(rsc)/./node_modules/secrets.js-grempe/secrets.js:19:48)
    at eval (webpack-internal:///(rsc)/./node_modules/secrets.js-grempe/secrets.js:22:3)
    at (rsc)/./node_modules/secrets.js-grempe/secrets.js (/Users/davidwong/projects/unwrittn/.next/server/vendor-chunks/secrets.js-grempe.js:20:1)
    at __webpack_require__ (/Users/davidwong/projects/unwrittn/.next/server/webpack-runtime.js:33:43)
    at eval (webpack-internal:///(rsc)/./node_modules/@bitgo/sdk-api/dist/src/bitgoAPI.js:21:16)
    at (rsc)/./node_modules/@bitgo/sdk-api/dist/src/bitgoAPI.js (/Users/davidwong/projects/unwrittn/.next/server/vendor-chunks/@bitgo.js:710:1)
    at __webpack_require__ (/Users/davidwong/projects/unwrittn/.next/server/webpack-runtime.js:33:43)
    at eval (webpack-internal:///(rsc)/./node_modules/@bitgo/sdk-api/dist/src/index.js:21:14)
    at (rsc)/./node_modules/@bitgo/sdk-api/dist/src/index.js (/Users/davidwong/projects/unwrittn/.next/server/vendor-chunks/@bitgo.js:730:1)
    at __webpack_require__ (/Users/davidwong/projects/unwrittn/.next/server/webpack-runtime.js:33:43)
    at eval (webpack-internal:///(rsc)/./app/(api)/btc/route.ts:5:72)
    at (rsc)/./app/(api)/btc/route.ts (/Users/davidwong/projects/unwrittn/.next/server/app/(api)/btc/route.js:381:1)
    at __webpack_require__ (/Users/davidwong/projects/unwrittn/.next/server/webpack-runtime.js:33:43)
    at eval (webpack-internal:///(rsc)/./node_modules/next/dist/build/webpack/loaders/next-app-loader.js?name=app%2F(api)%2Fbtc%2Froute&page=%2F(api)%2Fbtc%2Froute&appPaths=&pagePath=private-next-app-dir%2F(api)%2F
btc%2Froute.ts&appDir=%2FUsers%2Fdavidwong%2Fprojects%2Funwrittn%2Fapp&pageExtensions=tsx&pageExtensions=ts&pageExtensions=jsx&pageExtensions=js&rootDir=%2FUsers%2Fdavidwong%2Fprojects%2Funwrittn&isDev=true&tsconfi
gPath=tsconfig.json&basePath=&assetPrefix=&nextConfigOutput=&preferredRegion=&middlewareConfig=e30%3D!:16:113)
    at (rsc)/./node_modules/next/dist/build/webpack/loaders/next-app-loader.js?name=app%2F(api)%2Fbtc%2Froute&page=%2F(api)%2Fbtc%2Froute&appPaths=&pagePath=private-next-app-dir%2F(api)%2Fbtc%2Froute.ts&appDir=%2FU
sers%2Fdavidwong%2Fprojects%2Funwrittn%2Fapp&pageExtensions=tsx&pageExtensions=ts&pageExtensions=jsx&pageExtensions=js&rootDir=%2FUsers%2Fdavidwong%2Fprojects%2Funwrittn&isDev=true&tsconfigPath=tsconfig.json&basePa
th=&assetPrefix=&nextConfigOutput=&preferredRegion=&middlewareConfig=e30%3D! (/Users/davidwong/projects/unwrittn/.next/server/app/(api)/btc/route.js:370:1)
    at __webpack_require__ (/Users/davidwong/projects/unwrittn/.next/server/webpack-runtime.js:33:43)
    at __webpack_exec__ (/Users/davidwong/projects/unwrittn/.next/server/app/(api)/btc/route.js:391:39)
    at /Users/davidwong/projects/unwrittn/.next/server/app/(api)/btc/route.js:392:3889
    at __webpack_require__.X (/Users/davidwong/projects/unwrittn/.next/server/webpack-runtime.js:168:21)
    at /Users/davidwong/projects/unwrittn/.next/server/app/(api)/btc/route.js:392:47
    at Object.<anonymous> (/Users/davidwong/projects/unwrittn/.next/server/app/(api)/btc/route.js:395:3)
    at Module._compile (node:internal/modules/cjs/loader:1256:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1310:10)
    at Module.load (node:internal/modules/cjs/loader:1119:32)
    at Module._load (node:internal/modules/cjs/loader:960:12)
    at Module.require (node:internal/modules/cjs/loader:1143:19)
    at mod.require (/Users/davidwong/projects/unwrittn/node_modules/next/dist/server/require-hook.js:64:28)
    at require (node:internal/modules/cjs/helpers:119:18)
    at requirePage (/Users/davidwong/projects/unwrittn/node_modules/next/dist/server/require.js:109:84)
    at /Users/davidwong/projects/unwrittn/node_modules/next/dist/server/load-components.js:59:84
    at async loadComponentsImpl (/Users/davidwong/projects/unwrittn/node_modules/next/dist/server/load-components.js:59:26)
    at async DevServer.findPageComponentsImpl (/Users/davidwong/projects/unwrittn/node_modules/next/dist/server/next-server.js:439:36) {
  page: '/btc'
}

Possible Solution

Steps to Reproduce

npm i @bitgo/sdk-api @bitgo/sdk-coin-btc
copied https://github.com/BitGo/BitGoJS/blob/master/examples/ts/create-wallet-address.ts to my project
replaced the access key
ran the code and I get the error above

@dcmwong dcmwong added the bug label Nov 12, 2023
@KayBeSee
Copy link

KayBeSee commented Nov 16, 2023

I am getting the same error.

Trying to use the BitGo API npm package in a NextJS API route.

@dcmwong
Copy link
Author

dcmwong commented Nov 17, 2023

^ That's exactly what I'm doing. Forgot to mention in the bug report.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants