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

Error with require of node-fetch #8

Open
rubyshines opened this issue May 29, 2023 · 0 comments
Open

Error with require of node-fetch #8

rubyshines opened this issue May 29, 2023 · 0 comments

Comments

@rubyshines
Copy link

rubyshines commented May 29, 2023

I am getting the following error when I run the demo app. I have an implementation that cannot use import statements.

internal/modules/cjs/loader.js:1131
      throw new ERR_REQUIRE_ESM(filename, parentPath, packageJsonPath);
      ^

Error [ERR_REQUIRE_ESM]: Must use import to load ES Module: /Users/me/Downloads/simple-chatgpt-chat-streaming-demo-master/node_modules/node-fetch/src/index.js
require() of ES modules is not supported.
require() of /Users/me/Downloads/simple-chatgpt-chat-streaming-demo-master/node_modules/node-fetch/src/index.js from /Users/me/Downloads/simple-chatgpt-chat-streaming-demo-master/node_modules/streamed-chatgpt-api/index.js is an ES module file as it is a .js file whose nearest parent package.json contains "type": "module" which defines all .js files in that package scope as ES modules.
Instead rename /Users/me/Downloads/simple-chatgpt-chat-streaming-demo-master/node_modules/node-fetch/src/index.js to end in .cjs, change the requiring code to use import(), or remove "type": "module" from /Users/me/Downloads/simple-chatgpt-chat-streaming-demo-master/node_modules/node-fetch/package.json.

    at new NodeError (internal/errors.js:322:7)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1131:13)
    at Module.load (internal/modules/cjs/loader.js:979:32)
    at Function.Module._load (internal/modules/cjs/loader.js:819:12)
    at Module.require (internal/modules/cjs/loader.js:1003:19)
    at require (internal/modules/cjs/helpers.js:107:18)
    at Object.<anonymous> (/Users/me/Downloads/simple-chatgpt-chat-streaming-demo-master/node_modules/streamed-chatgpt-api/index.js:1:35)
    at Module._compile (internal/modules/cjs/loader.js:1114:14)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1143:10)
    at Module.load (internal/modules/cjs/loader.js:979:32) {
  code: 'ERR_REQUIRE_ESM'
}

Process finished with exit code 1

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

No branches or pull requests

1 participant