Skip to content
Discussion options

You must be logged in to vote

It seems like the code was encountering a module resolution issue with Parcel when using Styled Components in a React-based library within the main PHP application. This error might be related to the "process" module, which is typically a Node.js global object and not available in the browser environment.

To fix this issue, these are the steps I followed:

Install the browser-process-hrtime and process packages:

npm install browser-process-hrtime process

Create a shim.js file in your React library's source folder:

// src/shim.js
if (typeof process === 'undefined') {
  var process = require('process');
  process.hrtime = require('browser-process-hrtime');
  window.process = process;
}

Impo…

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by SrinivasPrabhu794
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant