Bounphone KOSADA
2 min readApr 30, 2023

process is not defined ReferenceError: process is not defined at eval (webpack-internal:///./node_modules/jsonwebtoken/lib/asymmetricKeyDetailsSupported.js:3:35) at ./node_modules/jsonwebtoken/lib/asymmetricKeyDetailsSupported.js (http://localhost:8080/js/chunk-vendors.js:2905:1) at __webpack_require__ (http://localhost:8080/js/app.js:1681:33) at fn (http://localhost:8080/js/app.js:1926:21) at eval (webpack-internal:///./node_modules/jsonwebtoken/lib/validateAsymmetricKey.js:1:42) at ./node_modules/jsonwebtoken/lib/validateAsymmetricKey.js (http://localhost:8080/js/chunk-vendors.js:2945:1) at __webpack_require__ (http://localhost:8080/js/app.js:1681:33) at fn (http://localhost:8080/js/app.js:1926:21) at eval (webpack-internal:///./node_modules/jsonwebtoken/verify.js:6:31) at ./node_modules/jsonwebtoken/verify.js (http://localhost:8080/js/chunk-vendors.js:2965:1)

The error message “ReferenceError: process is not defined” occurs when code that relies on the Node.js process global object is executed in an environment where the object is not available, such as a browser.

In this case, it looks like the jsonwebtoken library is trying to access the process object and failing because it is not available in your environment. To fix this issue, you can use a polyfill for the process object.

Here’s an example of how to use the process polyfill with webpack:

  • Install the process module:
npm install process
  • Add the following code to your webpack configuration:
const webpack = require('webpack');
module.exports = {
configureWebpack: {
plugins: [
new webpack.ProvidePlugin({
process: 'process/browser',
}),
],
}
};

This code tells webpack to use the process/browser module as a polyfill for the process global object. The ProvidePlugin is a webpack plugin that automatically imports modules for you when they are used in your code.

  • Save the changes to your webpack configuration file and rebuild your application. The error should be resolved.

I hope this helps you fix the issue. If you are still having trouble or have any questions, please let me know.

Your vue.config.js will look like:

No responses yet