darseen / amadeus-ts

Node library for the Amadeus travel APIs written in TypeScript
https://npmjs.com/package/amadeus-ts
MIT License
4 stars 2 forks source link

Error in Vercel NextJS deploy #2

Closed diegohdez90 closed 2 weeks ago

diegohdez90 commented 2 weeks ago

In the following snippet there is an error log in my deploy to vercel in a NextJS application

NextJS version: 15.0.1

[19:50:04.837] Running build in Washington, D.C., USA (East) – iad1
[19:50:04.996] Cloning github.com/diegohdez90/amadeus-next-tracking-fligths (Branch: main, Commit: 530286b)
[19:50:05.254] Cloning completed: 257.276ms
[19:50:05.400] Previous build cache not available
[19:50:05.599] Running "vercel build"
[19:50:06.002] Vercel CLI 37.13.0
[19:50:06.392] Warning: Due to "engines": { "node": "18.x" } in your `package.json` file, the Node.js Version defined in your Project Settings ("20.x") will not apply, Node.js Version "18.x" will be used instead. Learn More: http://vercel.link/node-version
[19:50:06.400] Running "install" command: `npm install --force`...
[19:50:06.716] npm warn using --force Recommended protections disabled.
[19:50:09.283] npm warn ERESOLVE overriding peer dependency
[19:50:09.284] npm warn While resolving: flowbite-react@0.10.2
[19:50:09.285] npm warn Found: react@19.0.0-rc-69d4b800-20241021
[19:50:09.285] npm warn node_modules/react
[19:50:09.285] npm warn   react@"19.0.0-rc-69d4b800-20241021" from the root project
[19:50:09.285] npm warn   4 more (next, react-dom, react-icons, styled-jsx)
[19:50:09.286] npm warn
[19:50:09.286] npm warn Could not resolve dependency:
[19:50:09.286] npm warn peer react@">=18" from flowbite-react@0.10.2
[19:50:09.286] npm warn node_modules/flowbite-react
[19:50:09.286] npm warn   flowbite-react@"^0.10.2" from the root project
[19:50:09.287] npm warn
[19:50:09.287] npm warn Conflicting peer dependency: react@18.3.1
[19:50:09.287] npm warn node_modules/react
[19:50:09.287] npm warn   peer react@">=18" from flowbite-react@0.10.2
[19:50:09.288] npm warn   node_modules/flowbite-react
[19:50:09.288] npm warn     flowbite-react@"^0.10.2" from the root project
[19:50:09.288] npm warn ERESOLVE overriding peer dependency
[19:50:09.288] npm warn While resolving: flowbite-react@0.10.2
[19:50:09.289] npm warn Found: react-dom@19.0.0-rc-69d4b800-20241021
[19:50:09.289] npm warn node_modules/react-dom
[19:50:09.289] npm warn   react-dom@"19.0.0-rc-69d4b800-20241021" from the root project
[19:50:09.289] npm warn   1 more (next)
[19:50:09.290] npm warn
[19:50:09.290] npm warn Could not resolve dependency:
[19:50:09.290] npm warn peer react-dom@">=18" from flowbite-react@0.10.2
[19:50:09.290] npm warn node_modules/flowbite-react
[19:50:09.291] npm warn   flowbite-react@"^0.10.2" from the root project
[19:50:09.291] npm warn
[19:50:09.291] npm warn Conflicting peer dependency: react-dom@18.3.1
[19:50:09.291] npm warn node_modules/react-dom
[19:50:09.292] npm warn   peer react-dom@">=18" from flowbite-react@0.10.2
[19:50:09.292] npm warn   node_modules/flowbite-react
[19:50:09.292] npm warn     flowbite-react@"^0.10.2" from the root project
[19:50:09.297] npm warn ERESOLVE overriding peer dependency
[19:50:09.298] npm warn While resolving: @floating-ui/react@0.26.21
[19:50:09.298] npm warn Found: react@19.0.0-rc-69d4b800-20241021
[19:50:09.298] npm warn node_modules/react
[19:50:09.298] npm warn   react@"19.0.0-rc-69d4b800-20241021" from the root project
[19:50:09.298] npm warn   4 more (next, react-dom, react-icons, styled-jsx)
[19:50:09.299] npm warn
[19:50:09.299] npm warn Could not resolve dependency:
[19:50:09.299] npm warn peer react@">=16.8.0" from @floating-ui/react@0.26.21
[19:50:09.299] npm warn node_modules/flowbite-react/node_modules/@floating-ui/react
[19:50:09.299] npm warn   @floating-ui/react@"0.26.21" from flowbite-react@0.10.2
[19:50:09.300] npm warn   node_modules/flowbite-react
[19:50:09.300] npm warn
[19:50:09.300] npm warn Conflicting peer dependency: react@18.3.1
[19:50:09.300] npm warn node_modules/react
[19:50:09.300] npm warn   peer react@">=16.8.0" from @floating-ui/react@0.26.21
[19:50:09.301] npm warn   node_modules/flowbite-react/node_modules/@floating-ui/react
[19:50:09.301] npm warn     @floating-ui/react@"0.26.21" from flowbite-react@0.10.2
[19:50:09.301] npm warn     node_modules/flowbite-react
[19:50:09.303] npm warn ERESOLVE overriding peer dependency
[19:50:09.303] npm warn While resolving: @floating-ui/react@0.26.21
[19:50:09.304] npm warn Found: react-dom@19.0.0-rc-69d4b800-20241021
[19:50:09.304] npm warn node_modules/react-dom
[19:50:09.304] npm warn   react-dom@"19.0.0-rc-69d4b800-20241021" from the root project
[19:50:09.304] npm warn   1 more (next)
[19:50:09.304] npm warn
[19:50:09.305] npm warn Could not resolve dependency:
[19:50:09.305] npm warn peer react-dom@">=16.8.0" from @floating-ui/react@0.26.21
[19:50:09.305] npm warn node_modules/flowbite-react/node_modules/@floating-ui/react
[19:50:09.305] npm warn   @floating-ui/react@"0.26.21" from flowbite-react@0.10.2
[19:50:09.305] npm warn   node_modules/flowbite-react
[19:50:09.306] npm warn
[19:50:09.306] npm warn Conflicting peer dependency: react-dom@18.3.1
[19:50:09.306] npm warn node_modules/react-dom
[19:50:09.306] npm warn   peer react-dom@">=16.8.0" from @floating-ui/react@0.26.21
[19:50:09.306] npm warn   node_modules/flowbite-react/node_modules/@floating-ui/react
[19:50:09.307] npm warn     @floating-ui/react@"0.26.21" from flowbite-react@0.10.2
[19:50:09.307] npm warn     node_modules/flowbite-react
[19:50:09.309] npm warn ERESOLVE overriding peer dependency
[19:50:09.309] npm warn While resolving: @floating-ui/react-dom@2.1.2
[19:50:09.309] npm warn Found: react@19.0.0-rc-69d4b800-20241021
[19:50:09.309] npm warn node_modules/react
[19:50:09.310] npm warn   react@"19.0.0-rc-69d4b800-20241021" from the root project
[19:50:09.310] npm warn   4 more (next, react-dom, react-icons, styled-jsx)
[19:50:09.310] npm warn
[19:50:09.310] npm warn Could not resolve dependency:
[19:50:09.311] npm warn peer react@">=16.8.0" from @floating-ui/react-dom@2.1.2
[19:50:09.311] npm warn node_modules/flowbite-react/node_modules/@floating-ui/react/node_modules/@floating-ui/react-dom
[19:50:09.311] npm warn   @floating-ui/react-dom@"^2.1.1" from @floating-ui/react@0.26.21
[19:50:09.311] npm warn   node_modules/flowbite-react/node_modules/@floating-ui/react
[19:50:09.311] npm warn
[19:50:09.311] npm warn Conflicting peer dependency: react@18.3.1
[19:50:09.312] npm warn node_modules/react
[19:50:09.312] npm warn   peer react@">=16.8.0" from @floating-ui/react-dom@2.1.2
[19:50:09.312] npm warn   node_modules/flowbite-react/node_modules/@floating-ui/react/node_modules/@floating-ui/react-dom
[19:50:09.312] npm warn     @floating-ui/react-dom@"^2.1.1" from @floating-ui/react@0.26.21
[19:50:09.312] npm warn     node_modules/flowbite-react/node_modules/@floating-ui/react
[19:50:09.312] npm warn ERESOLVE overriding peer dependency
[19:50:09.313] npm warn While resolving: @floating-ui/react-dom@2.1.2
[19:50:09.313] npm warn Found: react-dom@19.0.0-rc-69d4b800-20241021
[19:50:09.313] npm warn node_modules/react-dom
[19:50:09.313] npm warn   react-dom@"19.0.0-rc-69d4b800-20241021" from the root project
[19:50:09.313] npm warn   1 more (next)
[19:50:09.314] npm warn
[19:50:09.314] npm warn Could not resolve dependency:
[19:50:09.314] npm warn peer react-dom@">=16.8.0" from @floating-ui/react-dom@2.1.2
[19:50:09.314] npm warn node_modules/flowbite-react/node_modules/@floating-ui/react/node_modules/@floating-ui/react-dom
[19:50:09.314] npm warn   @floating-ui/react-dom@"^2.1.1" from @floating-ui/react@0.26.21
[19:50:09.314] npm warn   node_modules/flowbite-react/node_modules/@floating-ui/react
[19:50:09.314] npm warn
[19:50:09.315] npm warn Conflicting peer dependency: react-dom@18.3.1
[19:50:09.315] npm warn node_modules/react-dom
[19:50:09.315] npm warn   peer react-dom@">=16.8.0" from @floating-ui/react-dom@2.1.2
[19:50:09.315] npm warn   node_modules/flowbite-react/node_modules/@floating-ui/react/node_modules/@floating-ui/react-dom
[19:50:09.315] npm warn     @floating-ui/react-dom@"^2.1.1" from @floating-ui/react@0.26.21
[19:50:09.315] npm warn     node_modules/flowbite-react/node_modules/@floating-ui/react
[19:50:11.693] npm warn deprecated rimraf@3.0.2: Rimraf versions prior to v4 are no longer supported
[19:50:12.036] npm warn deprecated npmlog@5.0.1: This package is no longer supported.
[19:50:12.409] npm warn deprecated inflight@1.0.6: This module is not supported, and leaks memory. Do not use it. Check out lru-cache if you want a good and tested way to coalesce async requests by a key value, which is much more comprehensive and powerful.
[19:50:12.710] npm warn deprecated glob@7.2.3: Glob versions prior to v9 are no longer supported
[19:50:13.021] npm warn deprecated gauge@3.0.2: This package is no longer supported.
[19:50:13.650] npm warn deprecated are-we-there-yet@2.0.0: This package is no longer supported.
[19:50:29.308] 
[19:50:29.308] added 520 packages, and audited 521 packages in 23s
[19:50:29.308] 
[19:50:29.308] 152 packages are looking for funding
[19:50:29.308]   run `npm fund` for details
[19:50:29.310] 
[19:50:29.310] found 0 vulnerabilities
[19:50:29.342] Detected Next.js version: 15.0.1
[19:50:29.347] Running "npm run build"
[19:50:29.613] 
[19:50:29.614] > amadeus-next-tracking-fligths@0.1.0 build
[19:50:29.614] > next build
[19:50:29.614] 
[19:50:31.292] Attention: Next.js now collects completely anonymous telemetry regarding usage.
[19:50:31.293] This information is used to shape Next.js' roadmap and prioritize features.
[19:50:31.293] You can learn more, including how to opt-out if you'd not like to participate in this anonymous program, by visiting the following URL:
[19:50:31.293] https://nextjs.org/telemetry
[19:50:31.293] 
[19:50:31.402]   ▲ Next.js 15.0.1
[19:50:31.402] 
[19:50:31.428]    Creating an optimized production build ...
[19:50:48.168] Failed to compile.
[19:50:48.169] 
[19:50:48.170] node:events
[19:50:48.170] Module build failed: UnhandledSchemeError: Reading from "node:events" is not handled by plugins (Unhandled scheme).
[19:50:48.170] Webpack supports "data:" and "file:" URIs by default.
[19:50:48.170] You may need an additional plugin to handle "node:" URIs.
[19:50:48.170]     at /vercel/path0/node_modules/next/dist/compiled/webpack/bundle5.js:28:401783
[19:50:48.170]     at Hook.eval [as callAsync] (eval at create (/vercel/path0/node_modules/next/dist/compiled/webpack/bundle5.js:13:28858), <anonymous>:6:1)
[19:50:48.170]     at Object.processResource (/vercel/path0/node_modules/next/dist/compiled/webpack/bundle5.js:28:401708)
[19:50:48.171]     at processResource (/vercel/path0/node_modules/next/dist/compiled/loader-runner/LoaderRunner.js:1:5308)
[19:50:48.171]     at iteratePitchingLoaders (/vercel/path0/node_modules/next/dist/compiled/loader-runner/LoaderRunner.js:1:4667)
[19:50:48.171]     at runLoaders (/vercel/path0/node_modules/next/dist/compiled/loader-runner/LoaderRunner.js:1:8590)
[19:50:48.171]     at NormalModule._doBuild (/vercel/path0/node_modules/next/dist/compiled/webpack/bundle5.js:28:401570)
[19:50:48.171]     at NormalModule.build (/vercel/path0/node_modules/next/dist/compiled/webpack/bundle5.js:28:403598)
[19:50:48.171]     at /vercel/path0/node_modules/next/dist/compiled/webpack/bundle5.js:28:82055
[19:50:48.171]     at NormalModule.needBuild (/vercel/path0/node_modules/next/dist/compiled/webpack/bundle5.js:28:407696)
[19:50:48.171] 
[19:50:48.171] Import trace for requested module:
[19:50:48.172] node:events
[19:50:48.172] ./node_modules/amadeus-ts/dist/index.mjs
[19:50:48.172] ./src/app/utils/amadeus.ts
[19:50:48.172] ./src/app/page.tsx
[19:50:48.172] 
[19:50:48.172] node:util
[19:50:48.172] Module build failed: UnhandledSchemeError: Reading from "node:util" is not handled by plugins (Unhandled scheme).
[19:50:48.172] Webpack supports "data:" and "file:" URIs by default.
[19:50:48.173] You may need an additional plugin to handle "node:" URIs.
[19:50:48.173]     at /vercel/path0/node_modules/next/dist/compiled/webpack/bundle5.js:28:401783
[19:50:48.173]     at Hook.eval [as callAsync] (eval at create (/vercel/path0/node_modules/next/dist/compiled/webpack/bundle5.js:13:28858), <anonymous>:6:1)
[19:50:48.173]     at Hook.CALL_ASYNC_DELEGATE [as _callAsync] (/vercel/path0/node_modules/next/dist/compiled/webpack/bundle5.js:13:26012)
[19:50:48.173]     at Object.processResource (/vercel/path0/node_modules/next/dist/compiled/webpack/bundle5.js:28:401708)
[19:50:48.173]     at processResource (/vercel/path0/node_modules/next/dist/compiled/loader-runner/LoaderRunner.js:1:5308)
[19:50:48.173]     at iteratePitchingLoaders (/vercel/path0/node_modules/next/dist/compiled/loader-runner/LoaderRunner.js:1:4667)
[19:50:48.173]     at runLoaders (/vercel/path0/node_modules/next/dist/compiled/loader-runner/LoaderRunner.js:1:8590)
[19:50:48.173]     at NormalModule._doBuild (/vercel/path0/node_modules/next/dist/compiled/webpack/bundle5.js:28:401570)
[19:50:48.174]     at NormalModule.build (/vercel/path0/node_modules/next/dist/compiled/webpack/bundle5.js:28:403598)
[19:50:48.174]     at /vercel/path0/node_modules/next/dist/compiled/webpack/bundle5.js:28:82055
[19:50:48.174] 
[19:50:48.174] Import trace for requested module:
[19:50:48.174] node:util
[19:50:48.174] ./node_modules/amadeus-ts/dist/index.mjs
[19:50:48.174] ./src/app/utils/amadeus.ts
[19:50:48.174] ./src/app/page.tsx
[19:50:48.174] 
[19:50:48.175] 
[19:50:48.175] > Build failed because of webpack errors
[19:50:48.218] Error: Command "npm run build" exited with 1
[19:50:49.318] 
darseen commented 2 weeks ago

Hi @diegohdez90, thank you for reporting this issue! The error logs you provided indicate that the amadeus-ts package is being used on the client, when it's only supposed to run server-side.

In the logs, the stack trace shows that amadeus-ts package is used in /src/app/utils/amadeus.ts which was imported in /src/app/page.tsx which is a client component. The package uses node.js modules, so it wouldn't work on the client.

I have taken a look at your amadeus-next-tracking-flights repository, and it seems that you are indeed using the package client-side

Solution

Please use the package only on the server, either inside an API route, server component or using server actions in next.js.

Also there is a major security risk in your code:

const API_KEY=process.env.NEXT_PUBLIC_API_KEY
const API_SECRET=process.env.NEXT_PUBLIC_API_SECRET

The API_KEY and API_SECRET are sensitive credentials and shouldn’t be prefixed with NEXT_PUBLIC_