You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I encountered the following error when setting up the jdm-editor library in a browser environment:
✘ [ERROR] TS2591: Cannot find name 'process'. Do you need to install type definitions for node? Try npm i --save-dev @types/node and then add 'node' to the types field in your tsconfig. [plugin angular-compiler] node_modules/immer/src/utils/errors.ts:40:5: 40 │ if (process.env.NODE_ENV !== "production") {
This issue seems to arise because the immer dependency is using process.env.NODE_ENV, which is a Node.js environment variable not available in browser environments.
Upon investigating further, I noticed that the issue can be resolved by adjusting the imports in the index.d.ts file. Specifically, the WritableDraft type is imported directly from immer/src/types/types-external, which leads to this issue. Replacing the import like this:
import{WritableDraft}from'immer';
resolved the problem in my setup.
Proposed Solution:
- import { WritableDraft } from 'immer/src/types/types-external';+ import { WritableDraft } from 'immer';
Perhaps update below for next build/release
The text was updated successfully, but these errors were encountered:
isawk
added a commit
to isawk/jdm-editor
that referenced
this issue
Feb 15, 2025
I encountered the following error when setting up the
jdm-editor
library in a browser environment:✘ [ERROR] TS2591: Cannot find name 'process'. Do you need to install type definitions for node? Try npm i --save-dev @types/node and then add 'node' to the types field in your tsconfig. [plugin angular-compiler] node_modules/immer/src/utils/errors.ts:40:5: 40 │ if (process.env.NODE_ENV !== "production") {
This issue seems to arise because the
immer
dependency is usingprocess.env.NODE_ENV
, which is a Node.js environment variable not available in browser environments.Upon investigating further, I noticed that the issue can be resolved by adjusting the imports in the
index.d.ts
file. Specifically, theWritableDraft
type is imported directly fromimmer/src/types/types-external
, which leads to this issue. Replacing the import like this:resolved the problem in my setup.
Proposed Solution:
Perhaps update below for next build/release
![image](https://private-user-images.githubusercontent.com/21027753/402325467-8af8e597-2df9-4916-8c65-dec16dc80de7.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzk2OTc2MTQsIm5iZiI6MTczOTY5NzMxNCwicGF0aCI6Ii8yMTAyNzc1My80MDIzMjU0NjctOGFmOGU1OTctMmRmOS00OTE2LThjNjUtZGVjMTZkYzgwZGU3LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMTYlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjE2VDA5MTUxNFomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTIzNzQ2YmFiMjkzZDFjZmEzNWU3MWY2YzBlMGM3NTA2MjY1NWMzMDc5MjA3NGJlNmQxZDNhN2RhMGQ3ZjVmZTkmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.92hoDpa_WheBJTrGQmcc2VzciXkobYvYTi-8vn1QMs0)
The text was updated successfully, but these errors were encountered: