medusa
medusa copied to clipboard
Docs(Code Issue): Code Issue in /admin/configuration
Preliminary Checks
- [X] This issue is not a duplicate. Before opening a new issue, please search existing issues: https://github.com/medusajs/medusa/issues
Issue Summary
11:04:57 AM [@medusajs/admin] An error occured while trying to load your custom Webpack config. See the error below for details:
import { withCustomWebpackConfig } from "@medusajs/admin"; ^^^^^^
SyntaxError: Cannot use import statement outside a module at internalCompileFunction (node:internal/vm:73:18) at wrapSafe (node:internal/modules/cjs/loader:1274:20) at Module._compile (node:internal/modules/cjs/loader:1320:27) at Module._extensions..js (node:internal/modules/cjs/loader:1414:10) at Module.load (node:internal/modules/cjs/loader:1197:32) at Module._load (node:internal/modules/cjs/loader:1013:12) at Module.require (node:internal/modules/cjs/loader:1225:19) at require (node:internal/modules/helpers:177:18) at getCustomWebpackConfig (/Users/nio/official/medusa/medusa-brands/node_modules/@medusajs/admin/node_modules/@medusajs/admin-ui/dist/index.js:45:5741) at async develop (/Users/nio/lifease/trash/eivape/official/medusa/medusa-eivape-brands/node_modules/@medusajs/admin/node_modules/@medusajs/admin-ui/dist/index.js:45:7376) 11:04:57 AM [@medusajs/admin] Exiting process
How can this issue be resolved?
No response
Are you interested in working on this issue?
- [ ] I would like to fix this issue
Thank you for submitting this issue! The example in the documentation should use CommonJS rather than ESM (so require instead of import.) So something like this:
const withCustomWebpackConfig = require("@medusajs/admin").withCustomWebpackConfig
module.exports = withCustomWebpackConfig((config, webpack) => {
config.plugins.push(
new webpack.DefinePlugin({
"process.env": {
NODE_ENV: JSON.stringify("production"),
API_URL:
JSON.stringify("https://api.medusa-commerce.com"),
},
})
)
return config
})
Will open a PR to fix this