admin管理员组

文章数量:1315372

I am confused with how octokit is using imports. How can I use commonJs and not set the module and module resolution to Node16.

If I import the App like:

import {App} from "@octokit/app";

I get an error when deploying the firebase function:

Error [ERR_REQUIRE_ESM]: require() of ES Module /Users/andrewmainella/Desktop/Social-Activity-Functions/functions/node_modules/@octokit/app/dist-node/index.js from /Users/andrewmainella/Desktop/Social-Activity-Functions/functions/lib/index.js not supported. Instead change the require of /Users/andrewmainella/Desktop/Social-Activity-Functions/functions/node_modules/@octokit/app/dist-node/index.js in /Users/andrewmainella/Desktop/Social-Activity-Functions/functions/lib/index.js to a dynamic import() which is available in all CommonJS modules.

If I import the App like:

import {App} from "octokit";

I get multiple errors:

There are types at '/Users/andrewmainella/Desktop/Social-Activity-Functions/functions/node_modules/@octokit/core/dist-types/types.d.ts', but this result could not be resolved under your current 'moduleResolution' setting. Consider updating to 'node16', 'nodenext', or 'bundler'.

Things that I have looked at and am confused about:

  1. .js?tab=readme-ov-file#usage, shows how to st up octokit. The problem is I am useing firebase functions which use commonjs. Octokit is not happy with this so do these things just not work together?

  2. Trying to import octokit directly and useing dynamic imports all face other errors.

Any help or direction would be appretiated.

I am confused with how octokit is using imports. How can I use commonJs and not set the module and module resolution to Node16.

If I import the App like:

import {App} from "@octokit/app";

I get an error when deploying the firebase function:

Error [ERR_REQUIRE_ESM]: require() of ES Module /Users/andrewmainella/Desktop/Social-Activity-Functions/functions/node_modules/@octokit/app/dist-node/index.js from /Users/andrewmainella/Desktop/Social-Activity-Functions/functions/lib/index.js not supported. Instead change the require of /Users/andrewmainella/Desktop/Social-Activity-Functions/functions/node_modules/@octokit/app/dist-node/index.js in /Users/andrewmainella/Desktop/Social-Activity-Functions/functions/lib/index.js to a dynamic import() which is available in all CommonJS modules.

If I import the App like:

import {App} from "octokit";

I get multiple errors:

There are types at '/Users/andrewmainella/Desktop/Social-Activity-Functions/functions/node_modules/@octokit/core/dist-types/types.d.ts', but this result could not be resolved under your current 'moduleResolution' setting. Consider updating to 'node16', 'nodenext', or 'bundler'.

Things that I have looked at and am confused about:

  1. https://github/octokit/octokit.js?tab=readme-ov-file#usage, shows how to st up octokit. The problem is I am useing firebase functions which use commonjs. Octokit is not happy with this so do these things just not work together?

  2. Trying to import octokit directly and useing dynamic imports all face other errors.

Any help or direction would be appretiated.

Share Improve this question edited Jan 30 at 13:47 Doug Stevenson 318k36 gold badges454 silver badges472 bronze badges Recognized by Google Cloud Collective asked Jan 30 at 9:35 Andrew MainellaAndrew Mainella 411 silver badge3 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 0

I made a rookie mistake. ESM modules should have a package.json with "type": "module". Also, the eslint file needs to have a cjs extension in ESM. This as well as making changes to the tsconfig will allow the build to deploy correctly to cloud run!

本文标签: nodejsHow can I use octokit with commonJsStack Overflow