You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In BFF mode, where the api directory is at the root level, using @octokit/auth-oauth-user gets a TypeError error.
TypeError: Unknown file extension ".ts"for F:\Github\xx\xx\api\lambda\redirect\auth.ts
at Object.getFileProtocolModuleFormat [as file:] (node:internal/modules/esm/get_format:160:9)
at defaultGetFormat (node:internal/modules/esm/get_format:203:36)
at defaultLoad (node:internal/modules/esm/load:143:22)
at async ModuleLoader.load (node:internal/modules/esm/loader:553:7)
at async ModuleLoader.moduleProvider (node:internal/modules/esm/loader:434:45)
at async link (node:internal/modules/esm/module_job:87:21) {
code: 'ERR_UNKNOWN_FILE_EXTENSION'
}
error TypeError: Cannot destructure property 'module' of 'moduleInfo' as it is null.
Since this package is a pure esm package and we recommend using dual package as much as possible. Modern.js server runs in commonjs format by default and has basic support for esm projects, so if you want to use this package directly, you'll need to transform the project to esm:
Specify the type field as module in the package.json of the project:
Add the suffix .js
If the code in the server, api, shared directories in the project is imported by a relative path, the .js suffix needs to be added after the file name, for example:
import type { Vars } from '../shared/index.js';
const setPayload: UnstableMiddleware<Vars> = async (
c: UnstableMiddlewareContext<Vars>,
next,
) => {
c.set('message', 'message');
await next();
};
export const unstableMiddleware: UnstableMiddleware<Vars>[] = [setPayload];
Note that you can't use tsconfig paths in the server, api, shared directories, which are not currently supported with esm.
Version
modern.js `2.62.1`
Details
In BFF mode, where the api directory is at the root level, using @octokit/auth-oauth-user gets a TypeError error.
Reproduce link
https://github.com/veaba/error-projects-list
Reproduce Steps
cd modern-bff-module-error pnpm install pnpm run dev
The text was updated successfully, but these errors were encountered: