Closed la-ruee-vers-le-bois closed 4 weeks ago
Hi,
Any idea ?
Thx :)
can you add medusa as part of the externals in your nextjs webpack config. I suspect that it comes from webpack
Hi and thx for your response.
Can you provide an example please ?
could you try to add the following in yout next.config.js
just to see what you get
experimental: {
serverComponentsExternalPackages: [
"@medusajs/medusa",
],
},
Hi @adrien2p ,
It's the same:
# next.config.js
/** @type {import('next').NextConfig} */
const nextConfig = {
experimental: {
serverComponentsExternalPackages: ['@medusajs/medusa'],
serverActions: true,
// logging: 'verbose',
},
images: {
remotePatterns: [...],
},
};
module.exports = nextConfig;
When I start my project:
> Found a change in next.config.js. Restarting the server to apply the changes...
- ready started server on 0.0.0.0:3000, url: http://localhost:3000
- info Loaded env from /home/benjam/projects/lrvlb/portal/.env
- warn You have enabled experimental features (serverComponentsExternalPackages, serverActions) in next.config.js.
- warn Experimental features are not covered by semver, and may cause unexpected or broken application behavior. Use at your own risk.
- event compiled client and server successfully in 681 ms (306 modules)
- warn `export const config` in /home/benjam/projects/lrvlb/portal/app/middleware.js is deprecated. Please change `runtime` property to segment export config. See https://nextjs.org/docs/app/api-reference/file-conventions/route-segment-config
- wait compiling...
- event compiled client and server successfully in 188 ms (306 modules)
- wait compiling /_error (client and server)...
- event compiled client and server successfully in 505 ms (307 modules)
- warn Fast Refresh had to perform a full reload due to a runtime error.
- wait compiling /page (client and server)...
- error ./node_modules/@medusajs/medusa-cli/dist/commands/new.js:10:0
Module not found: Can't resolve 'child_process'
https://nextjs.org/docs/messages/module-not-found
Import trace for requested module:
./node_modules/@medusajs/medusa-cli/dist/create-cli.js
./node_modules/@medusajs/medusa-cli/dist/index.js
./node_modules/medusa-telemetry/dist/telemeter.js
./node_modules/medusa-telemetry/dist/index.js
./node_modules/@medusajs/medusa/dist/loaders/feature-flags/index.js
./node_modules/@medusajs/medusa/dist/utils/feature-flag-decorators.js
./node_modules/@medusajs/medusa/dist/models/analytics-config.js
./node_modules/@medusajs/medusa/dist/models/index.js
./node_modules/@medusajs/medusa/dist/index.js
./app/page.js
- wait compiling...
- error ./node_modules/@medusajs/medusa-cli/dist/commands/new.js:10:0
Module not found: Can't resolve 'child_process'
https://nextjs.org/docs/messages/module-not-found
Import trace for requested module:
./node_modules/@medusajs/medusa-cli/dist/create-cli.js
./node_modules/@medusajs/medusa-cli/dist/index.js
./node_modules/medusa-telemetry/dist/telemeter.js
./node_modules/medusa-telemetry/dist/index.js
./node_modules/@medusajs/medusa/dist/loaders/feature-flags/index.js
./node_modules/@medusajs/medusa/dist/utils/feature-flag-decorators.js
./node_modules/@medusajs/medusa/dist/models/analytics-config.js
./node_modules/@medusajs/medusa/dist/models/index.js
./node_modules/@medusajs/medusa/dist/index.js
./app/page.js
- warn `export const config` in /home/benjam/projects/lrvlb/portal/app/middleware.js is deprecated. Please change `runtime` property to segment export config. See https://nextjs.org/docs/app/api-reference/file-conventions/route-segment-config
- wait compiling /favicon.ico/route (client and server)...
- error ./node_modules/@medusajs/medusa-cli/dist/commands/new.js:10:0
Module not found: Can't resolve 'child_process'
https://nextjs.org/docs/messages/module-not-found
Import trace for requested module:
./node_modules/@medusajs/medusa-cli/dist/create-cli.js
./node_modules/@medusajs/medusa-cli/dist/index.js
./node_modules/medusa-telemetry/dist/telemeter.js
./node_modules/medusa-telemetry/dist/index.js
./node_modules/@medusajs/medusa/dist/loaders/feature-flags/index.js
./node_modules/@medusajs/medusa/dist/utils/feature-flag-decorators.js
./node_modules/@medusajs/medusa/dist/models/analytics-config.js
./node_modules/@medusajs/medusa/dist/models/index.js
./node_modules/@medusajs/medusa/dist/index.js
./app/page.js
No news on this? Running in to the same issue :-(
Can you try to use the nextjs config to update directly the webpack config to exclude medusa? you can find that in the next documentation. I suspect that for the client it is still not ignoring the package and therefore, child_process is a server node API which is not available when using webpack for this purpose
Ended up with running the project with NextJS new app structure.
i have same issue, is the medusa-react is not compatible for nextjs pages routing?
Hey, thanks for the report! Since v2 brought a lot of architectural and API changes on the backend, we will be closing this ticket since it no longer applies to our new setup, or the issue has already been fixed. If you are still facing issues with v1, please open a new ticket and we will address it as soon as possible. Thanks! 🙏
Bug report
Describe the bug
Hi :)
I had install the following packages:
Configure the provider and use a method to get products:
But use medusa-react with a nextjs project return the following error:
System information
Next project:
Medusa version (including plugins):
Node.js version:
Code snippets