Skip to content

reproduce fastify-cors problem#11

Closed
akphi wants to merge 2 commits intomainfrom
fastify-cors
Closed

reproduce fastify-cors problem#11
akphi wants to merge 2 commits intomainfrom
fastify-cors

Conversation

@akphi
Copy link
Owner

@akphi akphi commented Oct 11, 2022

To reproduce the issue, run the following command

yarn install
// after installing, I patch node_modules/@fastify/cors/index.d.ts to have
// export { fastifyCors }
// so this will clear the TS problem when compiling using tsc

yarn dev

You should see the following problem though:

import { fastifyCors } from "@fastify/cors";
         ^^^^^^^^^^^
SyntaxError: Named export 'fastifyCors' not found. The requested module '@fastify/cors' is a CommonJS module, which may not support all module.exports as named exports.
CommonJS modules can always be imported via the default export, for example using:

import pkg from '@fastify/cors';
const { fastifyCors } = pkg;

    at ModuleJob._instantiate (node:internal/modules/esm/module_job:123:21)
    at async ModuleJob.run (node:internal/modules/esm/module_job:189:5)
    at async Promise.all (index 0)
    at async ESMLoader.import (node:internal/modules/esm/loader:533:24)
    at async loadESM (node:internal/process/esm_loader:91:5)
    at async handleMainPromise (node:internal/modules/run_main:65:12)

@akphi akphi closed this Oct 14, 2022
@akphi akphi reopened this Oct 14, 2022
@akphi akphi closed this Oct 16, 2022
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 this pull request may close these issues.

1 participant