react ReferenceError: require is not defined #2915
Labels
No Label
DBF
Dates
Defined Names
Features
Formula
HTML
Images
Infrastructure
Integration
International
ODS
Operations
Performance
PivotTables
Pro
Protection
Read Bug
SSF
SYLK
Style
Write Bug
good first issue
No Milestone
No Assignees
2 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: sheetjs/sheetjs#2915
Loading…
Reference in New Issue
No description provided.
Delete Branch "%!s(<nil>)"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
I have a problem to import xlsx package.
when I write the third line of code,web exception occurred.
Your bundler is pulling the CJS version rather than ESM. Update to the latest version (https://docs.sheetjs.com/docs/getting-started/installation/frameworks if you are using a framework). If the error still persists, change the import statement to
I have tried the solution by your provide,but the problem still exists.
How was the project created? (are you using webpack or vite or some other bundler? Any overridden configurations?)
https://docs.sheetjs.com/docs/demos/frontend/react#array-of-objects the examples here were tested on February 28 against
create-react-app@5.0.1
andreact-scripts@5.0.1
.The project have a file that name is webpack.config.js
,created by
create-react-app.I don't know the version of
create-react-app`,because the project is created by a former employee of the business.Look in
package.json
for thereact-scripts
dependency. If the version is a relative number (e.g.^5.0.1
or~5.0.1
), runnpm ls
and look for the locally installed version ofreact-scripts
(in a Linux or MacOS system, you can runnpm ls | grep react-scripts
)Sorry!!It seems that there is no such configuration.
Ok this issue can be reproduced
How to reproduce (click to show)
Those versions are consistent with
react-scripts@2.1.3
. The issue can be reproduced with:Edit
src/App.js
:The development mode (
npm run start
) shows that error in the console.The way to fix the project is to forcefully use the standalone build:
When you do upgrade the project versions, you can go back to the normal imports.
Thank you so much.The above method is aviable.