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

migrate to cjs #162

Closed
Eomm opened this issue Sep 6, 2023 · 0 comments · Fixed by #163
Closed

migrate to cjs #162

Eomm opened this issue Sep 6, 2023 · 0 comments · Fixed by #163

Comments

@Eomm
Copy link
Collaborator

Eomm commented Sep 6, 2023

We should consider to migrate to cjm.

Right now:

const app = require('fastify')({ logger: true })
app.register(require('fastify-orama'))
app.get('/', async (request, reply) => {
  return { hello: 'world' }
})
app.post('/', async (request, reply) => {
  return request.body
})
app.listen({ port: 8080 })

Triggers:

/Users/mspigolon/workspace/_experiments/asd/asd.js:2
app.register(require('fastify-orama'))
             ^

Error [ERR_REQUIRE_ESM]: require() of ES Module /Users/mspigolon/workspace/_experiments/asd/node_modules/fastify-orama/index.js from /Users/mspigolon/workspace/_experiments/asd/asd.js not supported.
Instead change the require of index.js in /Users/mspigolon/workspace/_experiments/asd/asd.js to a dynamic import() which is available in all CommonJS modules.
    at Object.<anonymous> (/Users/mspigolon/workspace/_experiments/asd/asd.js:2:14) {
  code: 'ERR_REQUIRE_ESM'
}

Instead, working with cjs - it works with both cjs and esm without any issues.

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

Successfully merging a pull request may close this issue.

1 participant