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

6.0.2, cannot use in module #840

Closed
stheine opened this issue Apr 3, 2024 · 2 comments · Fixed by #843
Closed

6.0.2, cannot use in module #840

stheine opened this issue Apr 3, 2024 · 2 comments · Fixed by #843
Assignees
Labels
bug Something isn't working

Comments

@stheine
Copy link

stheine commented Apr 3, 2024

Describe the bug

I updated my app (in module syntax) from using http-cookie-agent@6.01 to 6.0.2.

now my app is failing with:

/js/test/node_modules/http-cookie-agent/dist/utils/validate_cookie_options.js:8
const _require = 'require' in globalThis ? globalThis.require : (0, _nodeModule.createRequire)(import.meta.url);
                                                                                                      ^^^^

SyntaxError: Cannot use 'import.meta' outside a module
    at internalCompileFunction (node:internal/vm:128:18)
    at wrapSafe (node:internal/modules/cjs/loader:1279:20)
    at Module._compile (node:internal/modules/cjs/loader:1331:27)
    at Module._extensions..js (node:internal/modules/cjs/loader:1426:10)
    at Module.load (node:internal/modules/cjs/loader:1205:32)
    at Module._load (node:internal/modules/cjs/loader:1021:12)
    at Module.require (node:internal/modules/cjs/loader:1230:19)
    at require (node:internal/modules/helpers:179:18)
    at Object.<anonymous> (/js/test/node_modules/http-cookie-agent/dist/undici/cookie_agent.js:8:32)
    at Module._compile (node:internal/modules/cjs/loader:1368:14)

Node.js v21.7.1

To Reproduce

create a dummy app with type module:

package.json:

{
  "name": "test",
  "type": "module",
  "dependencies": {
    "http-cookie-agent": "6.0.2",
    "tough-cookie": "4.1.3",
    "undici": "6.11.1"
  }
}

and an app test.js:

import { CookieAgent } from 'http-cookie-agent/undici';

then call the app

node test.js

and the above error shows.

change from 6.0.2 to 6.0.1 and the same works fine

Expected behavior

Work in module app

Code that reproduces the bug

see above

Environments

  • OS: Linux
  • Node.js version: 21.7.1
  • tough-cookie version: 4.1.3
@stheine stheine added the bug Something isn't working label Apr 3, 2024
3846masa added a commit that referenced this issue Apr 4, 2024
3846masa added a commit that referenced this issue Apr 4, 2024
@3846masa
Copy link
Owner

3846masa commented Apr 4, 2024

Thanks for reporting. Issue was fixed by v6.0.3.

3846masa pushed a commit that referenced this issue Apr 4, 2024
## [6.0.3](v6.0.2...v6.0.3) (2024-04-04)

### Bug Fixes

* remove createRequire code to generate commonjs ([#843](#843)) ([5a32bf1](5a32bf1)), closes [#840](#840) [#842](#842)
@stheine
Copy link
Author

stheine commented Apr 4, 2024

thanks, I can confirm the fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants