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:
.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?
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:
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?
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 badges1 Answer
Reset to default 0I 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
版权声明:本文标题:node.js - How can I use octokit with commonJs - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741975809a2408112.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论