question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Node.js API used in jose/dist/browser/runtime/env.js on line 6

See original GitHub issue

What happened?

I am using Jose in combination with Next.js (v12.2) middleware and an error is thrown due to process.versions being used inside jose/dist/browser/runtime/env.js on line 6. I suppose it could be replaced with simply checking typeof process === 'object to find out if it’s node, since the only thing done in this file is to check if it’s run inside node.

Version

4.18.1

Runtime

Browser

Runtime Details

Next.js (v12.2) middleware / only browser api available

Code to reproduce

Create a project with Next.js v12.2 and add import * as jose from 'jose' inside a middleware defined according to: https://nextjs.org/docs/advanced-features/middleware

Required

  • I have searched the issues tracker and discussions for similar topics and couldn’t find anything related.
  • I agree to follow this project’s Code of Conduct

Issue Analytics

  • State:closed
  • Created a year ago
  • Reactions:1
  • Comments:11 (3 by maintainers)

github_iconTop GitHub Comments

4reactions
panvacommented, Jun 29, 2022

@leerob @balazsorban44 how do you envision universal libraries doing runtime detection?

This here seems like a regression in Next.js. I think if it were to first do a typeof check on the process global and then continue off to access the versions and node properties it would still not allow these developers’ apps to run in 12.2 which ran just fine before

2reactions
panvacommented, Jun 29, 2022

v4.8.3 will be released shortly (pending CI) with the code from main which coincidentally removed the need for this anyway.

I’ll leave this open as https://github.com/panva/jose/labels/triage so that @leerob @balazsorban44 can pitch in.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Node-API | Node.js v19.3.0 Documentation
Node -API (formerly N-API) is an API for building native Addons. It is independent from the underlying JavaScript runtime (for example, V8) and...
Read more >
Node.js v19.3.0 Documentation
Creates a new CallTracker object which can be used to track if functions were called a specific number of times. The tracker.verify() must...
Read more >
Command-line API | Node.js v19.3.0 Documentation
Command-line API#. Node.js comes with a variety of CLI options. These options expose built-in debugging, multiple ways to execute scripts, and other helpful ......
Read more >
Process | Node.js v19.3.0 Documentation
The --trace-warnings command-line option can be used to have the default console output for warnings include the full stack trace of the warning....
Read more >
Node.js
Node.js® is a JavaScript runtime built on Chrome's V8 JavaScript engine.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found