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

Import Issues in Next.js 14 with Server Actions #16

Open
valentin-marquez opened this issue Apr 12, 2024 · 3 comments
Open

Import Issues in Next.js 14 with Server Actions #16

valentin-marquez opened this issue Apr 12, 2024 · 3 comments

Comments

@valentin-marquez
Copy link

valentin-marquez commented Apr 12, 2024

Problem Description

An import issue has been identified in Next.js 14 when using Server Actions. Although the project functions using memoryDriver, import errors are observed in the console when running the project. Even when recreating the issue in a new empty Next.js 14 template with App Router, import issues persist in the console, although it works at least using memoryDriver.

A minimal reproducible example has been provided in StackBlitz.

Steps to Reproduce the Problem

  1. Clone the repository bento-nextjs.
  2. Run npm install to install the dependencies.
  3. Run npm run dev to start the development server.

Console Output

Critical dependency: the request of a dependency is an expression

Import trace for requested module:
./node_modules/@poppinss/utils/build/index.js
./node_modules/bentocache/build/index.js
./bentocache.ts
./actions/counter.ts
./app/page.tsx

Project Dependencies

{
  "name": "bento-nextjs",
  "version": "0.1.0",
  "private": true,
  "scripts": {
    "dev": "next dev",
    "build": "next build",
    "start": "next start",
    "lint": "next lint"
  },
  "dependencies": {
    "bentocache": "^1.0.0-beta.8",
    "next": "14.2.0",
    "react": "^18",
    "react-dom": "^18"
  },
  "devDependencies": {
    "@types/node": "^20",
    "@types/react": "^18",
    "@types/react-dom": "^18",
    "eslint": "^8",
    "eslint-config-next": "14.2.0",
    "postcss": "^8",
    "tailwindcss": "^3.4.1",
    "typescript": "^5"
  }
}

Minimal Reproducible Example

The minimal reproducible example can be found in the provided StackBlitz.

Additional Information

Apparently, the import issue might be related to the usage of @poppinss/utils.

Any guidance or solution to address these import issues in Next.js 14 would be appreciated.

Thank you for your attention to this matter!

Sincerely,
Valentin

@Julien-R44
Copy link
Owner

Julien-R44 commented Apr 12, 2024

Hey. Thanks for the feedback

So, this is a problem with Next and more specifically Webpack. Here https://github.com/poppinss/utils/blob/develop/src/fs_import_all.ts#L47 we're using a dynamic await import, so with a variable. And webpack complains that it can't statically analyze what's imported.

So I would recommend two solutions:

  • Ignore and silence errors. As recommended and demonstrated by Typeorm here: https://typeorm.io/faq#how-to-use-webpack-for-the-backend. You could adapt the FilterWarning plugin to ignore this specific error
  • Use Turbopack. By testing on your repro, the error no longer appears when used with turbopack. I am not sure if this is a good advice, I am not using next nor turbopack, so I am not sure of the current state of Turbopack. But, the latest news from Next announces that 99.8% of tests passed with Turbopack, so I think it's pretty stable.

There's the /* webpackIgnore */ ( https://webpack.js.org/api/module-methods/#webpackignore ) solution that could be applied, but I'm not sure I want to do it as Next will be migrating to Turbopack very soon. You can use a patch to use this solution if you prefer

Let me know if it sounds good to you!

@gustaveWPM
Copy link

gustaveWPM commented Apr 18, 2024

Hello.
I faced the same issue since some months, and just ignored it until today.

I was using Bentocache to cache (in-memory) avatars URLs.

I'm now upgrading to Next Auth v5, and everything broke.

Got this error:

Import trace for requested module:
node:fs/promises
./node_modules/.pnpm/@poppinss+utils@6.7.3/node_modules/@poppinss/utils/build/index.js
./node_modules/.pnpm/bentocache@1.0.0-beta.8_tslib@2.6.2/node_modules/bentocache/build/index.js
./src/config/bentocache.ts
./src/config/Auth/authOptions.ts
./src/components/layouts/navbar/NavbarLoginButton.tsx

node:path
Module build failed: UnhandledSchemeError: Reading from "node:path" is not handled by plugins (Unhandled scheme).
Webpack supports "data:" and "file:" URIs by default.
You may need an additional plugin to handle "node:" URIs.
at /home/stan/Deliv/dashboard_rtm/node_modules/.pnpm/> next@14.2.1_@babel+core@7.24.4_@opentelemetry+api@1.8.0_react-dom@18.2.0_react@18.2.0__react@18.2.0/node_modules/next/dist/compiled/webpack/bundle5.js:30:401757

Tried to patch it like this:

// next.config.js
/* v8 ignore start */
// Stryker disable all
// @ts-check

const { webpack } = require('next/dist/compiled/webpack/webpack');

const { withContentlayer } = require('next-contentlayer');
const withBundleAnalyzer = require('@next/bundle-analyzer')({
  enabled: process.env.ANALYZE === 'true'
});

const ignoreBuildErrors = process.env.IGNORE_BUILD_ERRORS === 'true';
const ignoreEslintDuringBuilds = process.env.IGNORE_ESLINT_DURING_BUILDS === 'true';

/** @type {import('next').NextConfig} */
const nextConfig = {
  // eslint-disable-next-line require-await
  async redirects() {
    return [
      /* eslint-disable perfectionist/sort-objects */
      {
        source: '/:lng/lp',
        destination: '/:lng/lp/sign-up',
        permanent: true
      },
      {
        source: '/lp',
        destination: '/lp/sign-up',
        permanent: true
      }
      /* eslint-enable perfectionist/sort-objects */
    ];
  },

  // * ... here!
  webpack: (config) => {
    config.plugins.push(
      new webpack.NormalModuleReplacementPlugin(/node:/, (resource) => {
        resource.request = resource.request.replace(/^node:/, '');
      })
    );
    return config;
  },

  eslint: {
    ignoreDuringBuilds: ignoreEslintDuringBuilds
  },

  images: {
    domains: ['cdn.discordapp.com']
  },

  typescript: {
    ignoreBuildErrors
  },

  reactStrictMode: true,
  swcMinify: true
};

module.exports = withBundleAnalyzer(withContentlayer(nextConfig));

// Stryker restore all
/* v8 ignore stop */

See also: https://stackoverflow.com/questions/76500464/issues-while-using-gradio-client-in-next-js/76522223#76522223

Results in:

Generated 97 documents in .contentlayer
Failed to compile.

./node_modules/.pnpm/@poppinss+utils@6.7.3/node_modules/@poppinss/utils/build/index.js
Module not found: Can't resolve 'fs/promises'

https://nextjs.org/docs/messages/module-not-found

Import trace for requested module:
./node_modules/.pnpm/bentocache@1.0.0-beta.8_tslib@2.6.2/node_modules/bentocache/build/index.js
./src/config/bentocache.ts
./src/config/Auth/authOptions.ts
./src/components/layouts/navbar/NavbarLoginButton.tsx

Build failed because of webpack errors


EDIT:

Reproducible from here
Tirraa/dashboard_rtm@49f153f

Does it bring up more meaningful hints?

EDIT 2:
Exhaustive error message before trying to use the Webpack tricks exposed above.

node:buffer
Module build failed: UnhandledSchemeError: Reading from "node:buffer" is not handled by plugins (Unhandled scheme).
Webpack supports "data:" and "file:" URIs by default.
You may need an additional plugin to handle "node:" URIs.
    at /home/stan/Deliv/dashboard_rtm/node_modules/.pnpm/next@14.2.1_@babel+core@7.24.4_@opentelemetry+api@1.8.0_react-dom@18.2.0_react@18.2.0__react@18.2.0/node_modules/next/dist/compiled/webpack/bundle5.js:30:401757
    at Hook.eval [as callAsync] (eval at create (/home/stan/Deliv/dashboard_rtm/node_modules/.pnpm/next@14.2.1_@babel+core@7.24.4_@opentelemetry+api@1.8.0_react-dom@18.2.0_react@18.2.0__react@18.2.0/node_modules/next/dist/compiled/webpack/bundle5.js:15:28858), <anonymous>:6:1)
    at Object.processResource (/home/stan/Deliv/dashboard_rtm/node_modules/.pnpm/next@14.2.1_@babel+core@7.24.4_@opentelemetry+api@1.8.0_react-dom@18.2.0_react@18.2.0__react@18.2.0/node_modules/next/dist/compiled/webpack/bundle5.js:30:401682)
    at processResource (/home/stan/Deliv/dashboard_rtm/node_modules/.pnpm/next@14.2.1_@babel+core@7.24.4_@opentelemetry+api@1.8.0_react-dom@18.2.0_react@18.2.0__react@18.2.0/node_modules/next/dist/compiled/loader-runner/LoaderRunner.js:1:5308)
    at iteratePitchingLoaders (/home/stan/Deliv/dashboard_rtm/node_modules/.pnpm/next@14.2.1_@babel+core@7.24.4_@opentelemetry+api@1.8.0_react-dom@18.2.0_react@18.2.0__react@18.2.0/node_modules/next/dist/compiled/loader-runner/LoaderRunner.js:1:4667)
    at runLoaders (/home/stan/Deliv/dashboard_rtm/node_modules/.pnpm/next@14.2.1_@babel+core@7.24.4_@opentelemetry+api@1.8.0_react-dom@18.2.0_react@18.2.0__react@18.2.0/node_modules/next/dist/compiled/loader-runner/LoaderRunner.js:1:8590)
    at NormalModule._doBuild (/home/stan/Deliv/dashboard_rtm/node_modules/.pnpm/next@14.2.1_@babel+core@7.24.4_@opentelemetry+api@1.8.0_react-dom@18.2.0_react@18.2.0__react@18.2.0/node_modules/next/dist/compiled/webpack/bundle5.js:30:401544)
    at NormalModule.build (/home/stan/Deliv/dashboard_rtm/node_modules/.pnpm/next@14.2.1_@babel+core@7.24.4_@opentelemetry+api@1.8.0_react-dom@18.2.0_react@18.2.0__react@18.2.0/node_modules/next/dist/compiled/webpack/bundle5.js:30:403572)
    at /home/stan/Deliv/dashboard_rtm/node_modules/.pnpm/next@14.2.1_@babel+core@7.24.4_@opentelemetry+api@1.8.0_react-dom@18.2.0_react@18.2.0__react@18.2.0/node_modules/next/dist/compiled/webpack/bundle5.js:30:82055
    at NormalModule.needBuild (/home/stan/Deliv/dashboard_rtm/node_modules/.pnpm/next@14.2.1_@babel+core@7.24.4_@opentelemetry+api@1.8.0_react-dom@18.2.0_react@18.2.0__react@18.2.0/node_modules/next/dist/compiled/webpack/bundle5.js:30:407670)

Import trace for requested module:
node:buffer
./node_modules/.pnpm/@poppinss+utils@6.7.3/node_modules/@poppinss/utils/build/index.js
./node_modules/.pnpm/bentocache@1.0.0-beta.8_tslib@2.6.2/node_modules/bentocache/build/index.js
./src/config/bentocache.ts
./src/config/Auth/authOptions.ts
./src/components/layouts/navbar/NavbarLoginButton.tsx

node:crypto
Module build failed: UnhandledSchemeError: Reading from "node:crypto" is not handled by plugins (Unhandled scheme).
Webpack supports "data:" and "file:" URIs by default.
You may need an additional plugin to handle "node:" URIs.
    at /home/stan/Deliv/dashboard_rtm/node_modules/.pnpm/next@14.2.1_@babel+core@7.24.4_@opentelemetry+api@1.8.0_react-dom@18.2.0_react@18.2.0__react@18.2.0/node_modules/next/dist/compiled/webpack/bundle5.js:30:401757
    at Hook.eval [as callAsync] (eval at create (/home/stan/Deliv/dashboard_rtm/node_modules/.pnpm/next@14.2.1_@babel+core@7.24.4_@opentelemetry+api@1.8.0_react-dom@18.2.0_react@18.2.0__react@18.2.0/node_modules/next/dist/compiled/webpack/bundle5.js:15:28858), <anonymous>:6:1)
    at Object.processResource (/home/stan/Deliv/dashboard_rtm/node_modules/.pnpm/next@14.2.1_@babel+core@7.24.4_@opentelemetry+api@1.8.0_react-dom@18.2.0_react@18.2.0__react@18.2.0/node_modules/next/dist/compiled/webpack/bundle5.js:30:401682)
    at processResource (/home/stan/Deliv/dashboard_rtm/node_modules/.pnpm/next@14.2.1_@babel+core@7.24.4_@opentelemetry+api@1.8.0_react-dom@18.2.0_react@18.2.0__react@18.2.0/node_modules/next/dist/compiled/loader-runner/LoaderRunner.js:1:5308)
    at iteratePitchingLoaders (/home/stan/Deliv/dashboard_rtm/node_modules/.pnpm/next@14.2.1_@babel+core@7.24.4_@opentelemetry+api@1.8.0_react-dom@18.2.0_react@18.2.0__react@18.2.0/node_modules/next/dist/compiled/loader-runner/LoaderRunner.js:1:4667)
    at runLoaders (/home/stan/Deliv/dashboard_rtm/node_modules/.pnpm/next@14.2.1_@babel+core@7.24.4_@opentelemetry+api@1.8.0_react-dom@18.2.0_react@18.2.0__react@18.2.0/node_modules/next/dist/compiled/loader-runner/LoaderRunner.js:1:8590)
    at NormalModule._doBuild (/home/stan/Deliv/dashboard_rtm/node_modules/.pnpm/next@14.2.1_@babel+core@7.24.4_@opentelemetry+api@1.8.0_react-dom@18.2.0_react@18.2.0__react@18.2.0/node_modules/next/dist/compiled/webpack/bundle5.js:30:401544)
    at NormalModule.build (/home/stan/Deliv/dashboard_rtm/node_modules/.pnpm/next@14.2.1_@babel+core@7.24.4_@opentelemetry+api@1.8.0_react-dom@18.2.0_react@18.2.0__react@18.2.0/node_modules/next/dist/compiled/webpack/bundle5.js:30:403572)
    at /home/stan/Deliv/dashboard_rtm/node_modules/.pnpm/next@14.2.1_@babel+core@7.24.4_@opentelemetry+api@1.8.0_react-dom@18.2.0_react@18.2.0__react@18.2.0/node_modules/next/dist/compiled/webpack/bundle5.js:30:82055
    at NormalModule.needBuild (/home/stan/Deliv/dashboard_rtm/node_modules/.pnpm/next@14.2.1_@babel+core@7.24.4_@opentelemetry+api@1.8.0_react-dom@18.2.0_react@18.2.0__react@18.2.0/node_modules/next/dist/compiled/webpack/bundle5.js:30:407670)

Import trace for requested module:
node:crypto
./node_modules/.pnpm/@poppinss+utils@6.7.3/node_modules/@poppinss/utils/build/index.js
./node_modules/.pnpm/bentocache@1.0.0-beta.8_tslib@2.6.2/node_modules/bentocache/build/index.js
./src/config/bentocache.ts
./src/config/Auth/authOptions.ts
./src/components/layouts/navbar/NavbarLoginButton.tsx

node:events
Module build failed: UnhandledSchemeError: Reading from "node:events" is not handled by plugins (Unhandled scheme).
Webpack supports "data:" and "file:" URIs by default.
You may need an additional plugin to handle "node:" URIs.
    at /home/stan/Deliv/dashboard_rtm/node_modules/.pnpm/next@14.2.1_@babel+core@7.24.4_@opentelemetry+api@1.8.0_react-dom@18.2.0_react@18.2.0__react@18.2.0/node_modules/next/dist/compiled/webpack/bundle5.js:30:401757
    at Hook.eval [as callAsync] (eval at create (/home/stan/Deliv/dashboard_rtm/node_modules/.pnpm/next@14.2.1_@babel+core@7.24.4_@opentelemetry+api@1.8.0_react-dom@18.2.0_react@18.2.0__react@18.2.0/node_modules/next/dist/compiled/webpack/bundle5.js:15:28858), <anonymous>:6:1)
    at Hook.CALL_ASYNC_DELEGATE [as _callAsync] (/home/stan/Deliv/dashboard_rtm/node_modules/.pnpm/next@14.2.1_@babel+core@7.24.4_@opentelemetry+api@1.8.0_react-dom@18.2.0_react@18.2.0__react@18.2.0/node_modules/next/dist/compiled/webpack/bundle5.js:15:26012)
    at Object.processResource (/home/stan/Deliv/dashboard_rtm/node_modules/.pnpm/next@14.2.1_@babel+core@7.24.4_@opentelemetry+api@1.8.0_react-dom@18.2.0_react@18.2.0__react@18.2.0/node_modules/next/dist/compiled/webpack/bundle5.js:30:401682)
    at processResource (/home/stan/Deliv/dashboard_rtm/node_modules/.pnpm/next@14.2.1_@babel+core@7.24.4_@opentelemetry+api@1.8.0_react-dom@18.2.0_react@18.2.0__react@18.2.0/node_modules/next/dist/compiled/loader-runner/LoaderRunner.js:1:5308)
    at iteratePitchingLoaders (/home/stan/Deliv/dashboard_rtm/node_modules/.pnpm/next@14.2.1_@babel+core@7.24.4_@opentelemetry+api@1.8.0_react-dom@18.2.0_react@18.2.0__react@18.2.0/node_modules/next/dist/compiled/loader-runner/LoaderRunner.js:1:4667)
    at runLoaders (/home/stan/Deliv/dashboard_rtm/node_modules/.pnpm/next@14.2.1_@babel+core@7.24.4_@opentelemetry+api@1.8.0_react-dom@18.2.0_react@18.2.0__react@18.2.0/node_modules/next/dist/compiled/loader-runner/LoaderRunner.js:1:8590)
    at NormalModule._doBuild (/home/stan/Deliv/dashboard_rtm/node_modules/.pnpm/next@14.2.1_@babel+core@7.24.4_@opentelemetry+api@1.8.0_react-dom@18.2.0_react@18.2.0__react@18.2.0/node_modules/next/dist/compiled/webpack/bundle5.js:30:401544)
    at NormalModule.build (/home/stan/Deliv/dashboard_rtm/node_modules/.pnpm/next@14.2.1_@babel+core@7.24.4_@opentelemetry+api@1.8.0_react-dom@18.2.0_react@18.2.0__react@18.2.0/node_modules/next/dist/compiled/webpack/bundle5.js:30:403572)
    at /home/stan/Deliv/dashboard_rtm/node_modules/.pnpm/next@14.2.1_@babel+core@7.24.4_@opentelemetry+api@1.8.0_react-dom@18.2.0_react@18.2.0__react@18.2.0/node_modules/next/dist/compiled/webpack/bundle5.js:30:82055

Import trace for requested module:
node:events
./node_modules/.pnpm/bentocache@1.0.0-beta.8_tslib@2.6.2/node_modules/bentocache/build/index.js
./src/config/bentocache.ts
./src/config/Auth/authOptions.ts
./src/components/layouts/navbar/NavbarLoginButton.tsx

node:fs/promises
Module build failed: UnhandledSchemeError: Reading from "node:fs/promises" is not handled by plugins (Unhandled scheme).
Webpack supports "data:" and "file:" URIs by default.
You may need an additional plugin to handle "node:" URIs.
    at /home/stan/Deliv/dashboard_rtm/node_modules/.pnpm/next@14.2.1_@babel+core@7.24.4_@opentelemetry+api@1.8.0_react-dom@18.2.0_react@18.2.0__react@18.2.0/node_modules/next/dist/compiled/webpack/bundle5.js:30:401757
    at Hook.eval [as callAsync] (eval at create (/home/stan/Deliv/dashboard_rtm/node_modules/.pnpm/next@14.2.1_@babel+core@7.24.4_@opentelemetry+api@1.8.0_react-dom@18.2.0_react@18.2.0__react@18.2.0/node_modules/next/dist/compiled/webpack/bundle5.js:15:28858), <anonymous>:6:1)
    at Object.processResource (/home/stan/Deliv/dashboard_rtm/node_modules/.pnpm/next@14.2.1_@babel+core@7.24.4_@opentelemetry+api@1.8.0_react-dom@18.2.0_react@18.2.0__react@18.2.0/node_modules/next/dist/compiled/webpack/bundle5.js:30:401682)
    at processResource (/home/stan/Deliv/dashboard_rtm/node_modules/.pnpm/next@14.2.1_@babel+core@7.24.4_@opentelemetry+api@1.8.0_react-dom@18.2.0_react@18.2.0__react@18.2.0/node_modules/next/dist/compiled/loader-runner/LoaderRunner.js:1:5308)
    at iteratePitchingLoaders (/home/stan/Deliv/dashboard_rtm/node_modules/.pnpm/next@14.2.1_@babel+core@7.24.4_@opentelemetry+api@1.8.0_react-dom@18.2.0_react@18.2.0__react@18.2.0/node_modules/next/dist/compiled/loader-runner/LoaderRunner.js:1:4667)
    at runLoaders (/home/stan/Deliv/dashboard_rtm/node_modules/.pnpm/next@14.2.1_@babel+core@7.24.4_@opentelemetry+api@1.8.0_react-dom@18.2.0_react@18.2.0__react@18.2.0/node_modules/next/dist/compiled/loader-runner/LoaderRunner.js:1:8590)
    at NormalModule._doBuild (/home/stan/Deliv/dashboard_rtm/node_modules/.pnpm/next@14.2.1_@babel+core@7.24.4_@opentelemetry+api@1.8.0_react-dom@18.2.0_react@18.2.0__react@18.2.0/node_modules/next/dist/compiled/webpack/bundle5.js:30:401544)
    at NormalModule.build (/home/stan/Deliv/dashboard_rtm/node_modules/.pnpm/next@14.2.1_@babel+core@7.24.4_@opentelemetry+api@1.8.0_react-dom@18.2.0_react@18.2.0__react@18.2.0/node_modules/next/dist/compiled/webpack/bundle5.js:30:403572)
    at /home/stan/Deliv/dashboard_rtm/node_modules/.pnpm/next@14.2.1_@babel+core@7.24.4_@opentelemetry+api@1.8.0_react-dom@18.2.0_react@18.2.0__react@18.2.0/node_modules/next/dist/compiled/webpack/bundle5.js:30:82055
    at NormalModule.needBuild (/home/stan/Deliv/dashboard_rtm/node_modules/.pnpm/next@14.2.1_@babel+core@7.24.4_@opentelemetry+api@1.8.0_react-dom@18.2.0_react@18.2.0__react@18.2.0/node_modules/next/dist/compiled/webpack/bundle5.js:30:407670)

Import trace for requested module:
node:fs/promises
./node_modules/.pnpm/@poppinss+utils@6.7.3/node_modules/@poppinss/utils/build/index.js
./node_modules/.pnpm/bentocache@1.0.0-beta.8_tslib@2.6.2/node_modules/bentocache/build/index.js
./src/config/bentocache.ts
./src/config/Auth/authOptions.ts
./src/components/layouts/navbar/NavbarLoginButton.tsx

node:path
Module build failed: UnhandledSchemeError: Reading from "node:path" is not handled by plugins (Unhandled scheme).
Webpack supports "data:" and "file:" URIs by default.
You may need an additional plugin to handle "node:" URIs.
    at /home/stan/Deliv/dashboard_rtm/node_modules/.pnpm/next@14.2.1_@babel+core@7.24.4_@opentelemetry+api@1.8.0_react-dom@18.2.0_react@18.2.0__react@18.2.0/node_modules/next/dist/compiled/webpack/bundle5.js:30:401757
    at Hook.eval [as callAsync] (eval at create (/home/stan/Deliv/dashboard_rtm/node_modules/.pnpm/next@14.2.1_@babel+core@7.24.4_@opentelemetry+api@1.8.0_react-dom@18.2.0_react@18.2.0__react@18.2.0/node_modules/next/dist/compiled/webpack/bundle5.js:15:28858), <anonymous>:6:1)
    at Object.processResource (/home/stan/Deliv/dashboard_rtm/node_modules/.pnpm/next@14.2.1_@babel+core@7.24.4_@opentelemetry+api@1.8.0_react-dom@18.2.0_react@18.2.0__react@18.2.0/node_modules/next/dist/compiled/webpack/bundle5.js:30:401682)
    at processResource (/home/stan/Deliv/dashboard_rtm/node_modules/.pnpm/next@14.2.1_@babel+core@7.24.4_@opentelemetry+api@1.8.0_react-dom@18.2.0_react@18.2.0__react@18.2.0/node_modules/next/dist/compiled/loader-runner/LoaderRunner.js:1:5308)
    at iteratePitchingLoaders (/home/stan/Deliv/dashboard_rtm/node_modules/.pnpm/next@14.2.1_@babel+core@7.24.4_@opentelemetry+api@1.8.0_react-dom@18.2.0_react@18.2.0__react@18.2.0/node_modules/next/dist/compiled/loader-runner/LoaderRunner.js:1:4667)
    at runLoaders (/home/stan/Deliv/dashboard_rtm/node_modules/.pnpm/next@14.2.1_@babel+core@7.24.4_@opentelemetry+api@1.8.0_react-dom@18.2.0_react@18.2.0__react@18.2.0/node_modules/next/dist/compiled/loader-runner/LoaderRunner.js:1:8590)
    at NormalModule._doBuild (/home/stan/Deliv/dashboard_rtm/node_modules/.pnpm/next@14.2.1_@babel+core@7.24.4_@opentelemetry+api@1.8.0_react-dom@18.2.0_react@18.2.0__react@18.2.0/node_modules/next/dist/compiled/webpack/bundle5.js:30:401544)
    at NormalModule.build (/home/stan/Deliv/dashboard_rtm/node_modules/.pnpm/next@14.2.1_@babel+core@7.24.4_@opentelemetry+api@1.8.0_react-dom@18.2.0_react@18.2.0__react@18.2.0/node_modules/next/dist/compiled/webpack/bundle5.js:30:403572)
    at /home/stan/Deliv/dashboard_rtm/node_modules/.pnpm/next@14.2.1_@babel+core@7.24.4_@opentelemetry+api@1.8.0_react-dom@18.2.0_react@18.2.0__react@18.2.0/node_modules/next/dist/compiled/webpack/bundle5.js:30:82055
    at NormalModule.needBuild (/home/stan/Deliv/dashboard_rtm/node_modules/.pnpm/next@14.2.1_@babel+core@7.24.4_@opentelemetry+api@1.8.0_react-dom@18.2.0_react@18.2.0__react@18.2.0/node_modules/next/dist/compiled/webpack/bundle5.js:30:407670)

Import trace for requested module:
node:path
./node_modules/.pnpm/@poppinss+utils@6.7.3/node_modules/@poppinss/utils/build/index.js
./node_modules/.pnpm/bentocache@1.0.0-beta.8_tslib@2.6.2/node_modules/bentocache/build/index.js
./src/config/bentocache.ts
./src/config/Auth/authOptions.ts
./src/components/layouts/navbar/NavbarLoginButton.tsx

@gustaveWPM
Copy link

gustaveWPM commented Apr 20, 2024

Built again from scratch a project with Next Auth v5.

./node_modules/.pnpm/@poppinss+utils@6.7.3/node_modules/@poppinss/utils/build/index.js
Critical dependency: the request of a dependency is an expression

Import trace for requested module:
./node_modules/.pnpm/@poppinss+utils@6.7.3/node_modules/@poppinss/utils/build/index.js
./node_modules/.pnpm/bentocache@1.0.0-beta.8_tslib@2.6.2/node_modules/bentocache/build/index.js
./src/config/bentocache.ts
./src/auth.ts
./src/app/api/[...nextauth]/route.ts

Failed to compile.

node:crypto
Module build failed: UnhandledSchemeError: Reading from "node:crypto" is not handled by plugins (Unhandled scheme).
Webpack supports "data:" and "file:" URIs by default.
You may need an additional plugin to handle "node:" URIs.
    at /home/stan/Deliv/next-auth-v5-test/node_modules/.pnpm/next@14.2.2_react-dom@18.2.0_react@18.2.0__react@18.2.0/node_modules/next/dist/compiled/webpack/bundle5.js:30:401757
    at Hook.eval [as callAsync] (eval at create (/home/stan/Deliv/next-auth-v5-test/node_modules/.pnpm/next@14.2.2_react-dom@18.2.0_react@18.2.0__react@18.2.0/node_modules/next/dist/compiled/webpack/bundle5.js:15:28858), <anonymous>:6:1)
    at Object.processResource (/home/stan/Deliv/next-auth-v5-test/node_modules/.pnpm/next@14.2.2_react-dom@18.2.0_react@18.2.0__react@18.2.0/node_modules/next/dist/compiled/webpack/bundle5.js:30:401682)
    at processResource (/home/stan/Deliv/next-auth-v5-test/node_modules/.pnpm/next@14.2.2_react-dom@18.2.0_react@18.2.0__react@18.2.0/node_modules/next/dist/compiled/loader-runner/LoaderRunner.js:1:5308)
    at iteratePitchingLoaders (/home/stan/Deliv/next-auth-v5-test/node_modules/.pnpm/next@14.2.2_react-dom@18.2.0_react@18.2.0__react@18.2.0/node_modules/next/dist/compiled/loader-runner/LoaderRunner.js:1:4667)
    at runLoaders (/home/stan/Deliv/next-auth-v5-test/node_modules/.pnpm/next@14.2.2_react-dom@18.2.0_react@18.2.0__react@18.2.0/node_modules/next/dist/compiled/loader-runner/LoaderRunner.js:1:8590)
    at NormalModule._doBuild (/home/stan/Deliv/next-auth-v5-test/node_modules/.pnpm/next@14.2.2_react-dom@18.2.0_react@18.2.0__react@18.2.0/node_modules/next/dist/compiled/webpack/bundle5.js:30:401544)
    at NormalModule.build (/home/stan/Deliv/next-auth-v5-test/node_modules/.pnpm/next@14.2.2_react-dom@18.2.0_react@18.2.0__react@18.2.0/node_modules/next/dist/compiled/webpack/bundle5.js:30:403572)
    at /home/stan/Deliv/next-auth-v5-test/node_modules/.pnpm/next@14.2.2_react-dom@18.2.0_react@18.2.0__react@18.2.0/node_modules/next/dist/compiled/webpack/bundle5.js:30:82055
    at NormalModule.needBuild (/home/stan/Deliv/next-auth-v5-test/node_modules/.pnpm/next@14.2.2_react-dom@18.2.0_react@18.2.0__react@18.2.0/node_modules/next/dist/compiled/webpack/bundle5.js:30:407670)

Import trace for requested module:
node:crypto
./node_modules/.pnpm/@poppinss+utils@6.7.3/node_modules/@poppinss/utils/build/index.js
./node_modules/.pnpm/bentocache@1.0.0-beta.8_tslib@2.6.2/node_modules/bentocache/build/index.js
./src/config/bentocache.ts
./src/auth.ts

node:fs/promises
Module build failed: UnhandledSchemeError: Reading from "node:fs/promises" is not handled by plugins (Unhandled scheme).
Webpack supports "data:" and "file:" URIs by default.
You may need an additional plugin to handle "node:" URIs.
    at /home/stan/Deliv/next-auth-v5-test/node_modules/.pnpm/next@14.2.2_react-dom@18.2.0_react@18.2.0__react@18.2.0/node_modules/next/dist/compiled/webpack/bundle5.js:30:401757
    at Hook.eval [as callAsync] (eval at create (/home/stan/Deliv/next-auth-v5-test/node_modules/.pnpm/next@14.2.2_react-dom@18.2.0_react@18.2.0__react@18.2.0/node_modules/next/dist/compiled/webpack/bundle5.js:15:28858), <anonymous>:6:1)
    at Object.processResource (/home/stan/Deliv/next-auth-v5-test/node_modules/.pnpm/next@14.2.2_react-dom@18.2.0_react@18.2.0__react@18.2.0/node_modules/next/dist/compiled/webpack/bundle5.js:30:401682)
    at processResource (/home/stan/Deliv/next-auth-v5-test/node_modules/.pnpm/next@14.2.2_react-dom@18.2.0_react@18.2.0__react@18.2.0/node_modules/next/dist/compiled/loader-runner/LoaderRunner.js:1:5308)
    at iteratePitchingLoaders (/home/stan/Deliv/next-auth-v5-test/node_modules/.pnpm/next@14.2.2_react-dom@18.2.0_react@18.2.0__react@18.2.0/node_modules/next/dist/compiled/loader-runner/LoaderRunner.js:1:4667)
    at runLoaders (/home/stan/Deliv/next-auth-v5-test/node_modules/.pnpm/next@14.2.2_react-dom@18.2.0_react@18.2.0__react@18.2.0/node_modules/next/dist/compiled/loader-runner/LoaderRunner.js:1:8590)
    at NormalModule._doBuild (/home/stan/Deliv/next-auth-v5-test/node_modules/.pnpm/next@14.2.2_react-dom@18.2.0_react@18.2.0__react@18.2.0/node_modules/next/dist/compiled/webpack/bundle5.js:30:401544)
    at NormalModule.build (/home/stan/Deliv/next-auth-v5-test/node_modules/.pnpm/next@14.2.2_react-dom@18.2.0_react@18.2.0__react@18.2.0/node_modules/next/dist/compiled/webpack/bundle5.js:30:403572)
    at /home/stan/Deliv/next-auth-v5-test/node_modules/.pnpm/next@14.2.2_react-dom@18.2.0_react@18.2.0__react@18.2.0/node_modules/next/dist/compiled/webpack/bundle5.js:30:82055
    at NormalModule.needBuild (/home/stan/Deliv/next-auth-v5-test/node_modules/.pnpm/next@14.2.2_react-dom@18.2.0_react@18.2.0__react@18.2.0/node_modules/next/dist/compiled/webpack/bundle5.js:30:407670)

Import trace for requested module:
node:fs/promises
./node_modules/.pnpm/@poppinss+utils@6.7.3/node_modules/@poppinss/utils/build/index.js
./node_modules/.pnpm/bentocache@1.0.0-beta.8_tslib@2.6.2/node_modules/bentocache/build/index.js
./src/config/bentocache.ts
./src/auth.ts

node:path
Module build failed: UnhandledSchemeError: Reading from "node:path" is not handled by plugins (Unhandled scheme).
Webpack supports "data:" and "file:" URIs by default.
You may need an additional plugin to handle "node:" URIs.
    at /home/stan/Deliv/next-auth-v5-test/node_modules/.pnpm/next@14.2.2_react-dom@18.2.0_react@18.2.0__react@18.2.0/node_modules/next/dist/compiled/webpack/bundle5.js:30:401757
    at Hook.eval [as callAsync] (eval at create (/home/stan/Deliv/next-auth-v5-test/node_modules/.pnpm/next@14.2.2_react-dom@18.2.0_react@18.2.0__react@18.2.0/node_modules/next/dist/compiled/webpack/bundle5.js:15:28858), <anonymous>:6:1)
    at Object.processResource (/home/stan/Deliv/next-auth-v5-test/node_modules/.pnpm/next@14.2.2_react-dom@18.2.0_react@18.2.0__react@18.2.0/node_modules/next/dist/compiled/webpack/bundle5.js:30:401682)
    at processResource (/home/stan/Deliv/next-auth-v5-test/node_modules/.pnpm/next@14.2.2_react-dom@18.2.0_react@18.2.0__react@18.2.0/node_modules/next/dist/compiled/loader-runner/LoaderRunner.js:1:5308)
    at iteratePitchingLoaders (/home/stan/Deliv/next-auth-v5-test/node_modules/.pnpm/next@14.2.2_react-dom@18.2.0_react@18.2.0__react@18.2.0/node_modules/next/dist/compiled/loader-runner/LoaderRunner.js:1:4667)
    at runLoaders (/home/stan/Deliv/next-auth-v5-test/node_modules/.pnpm/next@14.2.2_react-dom@18.2.0_react@18.2.0__react@18.2.0/node_modules/next/dist/compiled/loader-runner/LoaderRunner.js:1:8590)
    at NormalModule._doBuild (/home/stan/Deliv/next-auth-v5-test/node_modules/.pnpm/next@14.2.2_react-dom@18.2.0_react@18.2.0__react@18.2.0/node_modules/next/dist/compiled/webpack/bundle5.js:30:401544)
    at NormalModule.build (/home/stan/Deliv/next-auth-v5-test/node_modules/.pnpm/next@14.2.2_react-dom@18.2.0_react@18.2.0__react@18.2.0/node_modules/next/dist/compiled/webpack/bundle5.js:30:403572)
    at /home/stan/Deliv/next-auth-v5-test/node_modules/.pnpm/next@14.2.2_react-dom@18.2.0_react@18.2.0__react@18.2.0/node_modules/next/dist/compiled/webpack/bundle5.js:30:82055
    at NormalModule.needBuild (/home/stan/Deliv/next-auth-v5-test/node_modules/.pnpm/next@14.2.2_react-dom@18.2.0_react@18.2.0__react@18.2.0/node_modules/next/dist/compiled/webpack/bundle5.js:30:407670)

Import trace for requested module:
node:path
./node_modules/.pnpm/@poppinss+utils@6.7.3/node_modules/@poppinss/utils/build/index.js
./node_modules/.pnpm/bentocache@1.0.0-beta.8_tslib@2.6.2/node_modules/bentocache/build/index.js
./src/config/bentocache.ts
./src/auth.ts

node:url
Module build failed: UnhandledSchemeError: Reading from "node:url" is not handled by plugins (Unhandled scheme).
Webpack supports "data:" and "file:" URIs by default.
You may need an additional plugin to handle "node:" URIs.
    at /home/stan/Deliv/next-auth-v5-test/node_modules/.pnpm/next@14.2.2_react-dom@18.2.0_react@18.2.0__react@18.2.0/node_modules/next/dist/compiled/webpack/bundle5.js:30:401757
    at Hook.eval [as callAsync] (eval at create (/home/stan/Deliv/next-auth-v5-test/node_modules/.pnpm/next@14.2.2_react-dom@18.2.0_react@18.2.0__react@18.2.0/node_modules/next/dist/compiled/webpack/bundle5.js:15:28858), <anonymous>:6:1)
    at Hook.CALL_ASYNC_DELEGATE [as _callAsync] (/home/stan/Deliv/next-auth-v5-test/node_modules/.pnpm/next@14.2.2_react-dom@18.2.0_react@18.2.0__react@18.2.0/node_modules/next/dist/compiled/webpack/bundle5.js:15:26012)
    at Object.processResource (/home/stan/Deliv/next-auth-v5-test/node_modules/.pnpm/next@14.2.2_react-dom@18.2.0_react@18.2.0__react@18.2.0/node_modules/next/dist/compiled/webpack/bundle5.js:30:401682)
    at processResource (/home/stan/Deliv/next-auth-v5-test/node_modules/.pnpm/next@14.2.2_react-dom@18.2.0_react@18.2.0__react@18.2.0/node_modules/next/dist/compiled/loader-runner/LoaderRunner.js:1:5308)
    at iteratePitchingLoaders (/home/stan/Deliv/next-auth-v5-test/node_modules/.pnpm/next@14.2.2_react-dom@18.2.0_react@18.2.0__react@18.2.0/node_modules/next/dist/compiled/loader-runner/LoaderRunner.js:1:4667)
    at runLoaders (/home/stan/Deliv/next-auth-v5-test/node_modules/.pnpm/next@14.2.2_react-dom@18.2.0_react@18.2.0__react@18.2.0/node_modules/next/dist/compiled/loader-runner/LoaderRunner.js:1:8590)
    at NormalModule._doBuild (/home/stan/Deliv/next-auth-v5-test/node_modules/.pnpm/next@14.2.2_react-dom@18.2.0_react@18.2.0__react@18.2.0/node_modules/next/dist/compiled/webpack/bundle5.js:30:401544)
    at NormalModule.build (/home/stan/Deliv/next-auth-v5-test/node_modules/.pnpm/next@14.2.2_react-dom@18.2.0_react@18.2.0__react@18.2.0/node_modules/next/dist/compiled/webpack/bundle5.js:30:403572)
    at /home/stan/Deliv/next-auth-v5-test/node_modules/.pnpm/next@14.2.2_react-dom@18.2.0_react@18.2.0__react@18.2.0/node_modules/next/dist/compiled/webpack/bundle5.js:30:82055

Import trace for requested module:
node:url
./node_modules/.pnpm/@poppinss+utils@6.7.3/node_modules/@poppinss/utils/build/index.js
./node_modules/.pnpm/bentocache@1.0.0-beta.8_tslib@2.6.2/node_modules/bentocache/build/index.js
./src/config/bentocache.ts
./src/auth.ts

./src/config/bentocache.ts
Dynamic Code Evaluation (e. g. 'eval', 'new Function', 'WebAssembly.compile') not allowed in Edge Runtime 
Learn More: https://nextjs.org/docs/messages/edge-dynamic-code-evaluation

The error was caused by importing 'bentocache/build/index.js' in './src/config/bentocache.ts'.

Import trace for requested module:
  ./src/config/bentocache.ts
  ./src/auth.ts
  ./src/middleware.ts

Dynamic Code Evaluation (e. g. 'eval', 'new Function', 'WebAssembly.compile') not allowed in Edge Runtime
Learn More: https://nextjs.org/docs/messages/edge-dynamic-code-evaluation

Interesting...
It seems that the unification of the API using auth in Auth.js (formerly Next Auth) v5 reveals issues in Edge Runtime with Bentocache (depending on Poppinss, which causes this issue).

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

No branches or pull requests

3 participants