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

Unable to Build storefront #226

Open
herawais opened this issue Dec 21, 2023 · 4 comments
Open

Unable to Build storefront #226

herawais opened this issue Dec 21, 2023 · 4 comments

Comments

@herawais
Copy link

My node version is 21

What Medusa has to do with oracledb ?


Failed to compile.

./node_modules/knex/lib/dialects/oracledb/index.js
Module not found: Can't resolve 'oracledb'

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

Import trace for requested module:
./node_modules/knex/lib/dialects/index.js
./node_modules/knex/lib/knex-builder/internal/config-resolver.js
./node_modules/knex/lib/knex-builder/Knex.js
./node_modules/knex/lib/index.js
./node_modules/knex/knex.js
./node_modules/@medusajs/utils/dist/modules-sdk/create-pg-connection.js
./node_modules/@medusajs/utils/dist/modules-sdk/index.js
./node_modules/@medusajs/utils/dist/index.js
./node_modules/@medusajs/modules-sdk/dist/medusa-app.js
./node_modules/@medusajs/modules-sdk/dist/index.js
./src/app/api/products/route.ts

./node_modules/knex/lib/dialects/oracledb/utils.js
Module not found: Can't resolve 'oracledb'

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

Import trace for requested module:
./node_modules/knex/lib/dialects/oracledb/index.js
./node_modules/knex/lib/dialects/index.js
./node_modules/knex/lib/knex-builder/internal/config-resolver.js
./node_modules/knex/lib/knex-builder/Knex.js
./node_modules/knex/lib/index.js
./node_modules/knex/knex.js
./node_modules/@medusajs/utils/dist/modules-sdk/create-pg-connection.js
./node_modules/@medusajs/utils/dist/modules-sdk/index.js
./node_modules/@medusajs/utils/dist/index.js
./node_modules/@medusajs/modules-sdk/dist/medusa-app.js
./node_modules/@medusajs/modules-sdk/dist/index.js
./src/app/api/products/route.ts

./node_modules/@mikro-orm/postgresql/node_modules/pg/lib/crypto/utils.js
Error:
× Return statement is not allowed here
╭─[/medusa/node_modules/@mikro-orm/postgresql/node_modules/pg/lib/crypto/utils.js:4:1]
4 │ if (useLegacyCrypto) {
5 │ // We are on an old version of Node.js that requires legacy crypto utilities.
6 │ module.exports = require('./utils-legacy')
7 │ return
· ──────
8 │ }
9 │
10 │ const nodeCrypto = require('crypto')
╰────

Caused by:
Syntax Error

Import trace for requested module:
./node_modules/@mikro-orm/postgresql/node_modules/pg/lib/crypto/utils.js
./node_modules/@mikro-orm/postgresql/node_modules/pg/lib/client.js
./node_modules/@mikro-orm/postgresql/node_modules/pg/lib/index.js
./node_modules/@mikro-orm/postgresql/PostgreSqlPlatform.js
./node_modules/@mikro-orm/postgresql/index.js
./node_modules/@medusajs/utils/dist/dal/mikro-orm/mikro-orm-create-connection.js
./node_modules/@medusajs/utils/dist/dal/index.js
./node_modules/@medusajs/utils/dist/index.js
./node_modules/@medusajs/modules-sdk/dist/medusa-app.js
./node_modules/@medusajs/modules-sdk/dist/index.js
./src/app/api/products/route.ts

Build failed because of webpack errors

@woniuxingdong
Copy link

Same problem. To get it work, just remove all the code under src/app/api .

@durdenx
Copy link

durdenx commented Jan 12, 2024

Why we can't use medusajs in /app/api?

@florian-lefebvre
Copy link

florian-lefebvre commented Jan 12, 2024

There's a note at https://docs.medusajs.com/starters/nextjs-medusa-starter#using-serverless-modules:

If you're not planning on using the serverless modules, you might encounter errors when deploying to Vercel. You can safely delete or exclude the src/app/api folder before deploying. The API routes are only used by the serverless modules.

I can confirm this works

@pepijn-vanvlaanderen
Copy link

If you actually want to use those serverless modules, you need to add this to your next.config.ts:

    experimental: {
        serverComponentsExternalPackages: ['@mikro-orm/postgresql', '@mikro-orm/core', '@mikro-orm/knex'],
    },

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

5 participants