I want to use jsPDF library on React JS.
I added the library with 'npm i jspdf'
Then I imported jsPDF like this => import { jsPDF } from "jspdf";
In this way, I can get PDF outputs. So far, no problem. However, when I want to build with Vite, I get this error.
Could not resolve '../internals/define-globalThis-property' from ../internals/define-globalThis-property?commonjs-external error during build: Error: Could not resolve '../internals/define-globalThis-property' from ../internals/define-globalThis-property?commonjs-external at error (file:///C:/Users/BurakFircasig%C3%BCzel/Documents/react-projects/bf-v02-generator/node_modules/rollup/dist/es/shared/rollup.js:1858:30) at ModuleLoader.handleResolveId (file:///C:/Users/BurakFircasig%C3%BCzel/Documents/react-projects/bf-v02-generator/node_modules/rollup/dist/es/shared/rollup.js:22156:24) at file:///C:/Users/BurakFircasig%C3%BCzel/Documents/react-projects/bf-v02-generator/node_modules/rollup/dist/es/shared/rollup.js:22119:26
In this way, I can get PDF outputs. So far, no problem. However, when I want to build with Vite, I get this error.
This is my vite.config.js file.
I examined the steps one by one, I tried.
import { jsPDF } from "jspdf";
If I remove it, I get the build without any problems.
And of course I can't use jsPDF.
Is this issue related to Vite or jsPDF?
How can I solve this problem?
vite v3.2.5 building for production...
✓ 859 modules transformed.
Could not resolve '../internals/define-globalThis-property' from ../internals/define-globalThis-property?commonjs-external
error during build:
Error: Could not resolve '../internals/define-globalThis-property' from ../internals/define-globalThis-property?commonjs-external
at error (file:///C:/Users/BurakFircasig%C3%BCzel/Documents/react-projects/bf-v02-generator/node_modules/rollup/dist/es/shared/rollup.js:1858:30)
at ModuleLoader.handleResolveId (file:///C:/Users/BurakFircasig%C3%BCzel/Documents/react-projects/bf-v02-generator/node_modules/rollup/dist/es/shared/rollup.js:22156:24)
at file:///C:/Users/BurakFircasig%C3%BCzel/Documents/react-projects/bf-v02-generator/node_modules/rollup/dist/es/shared/rollup.js:22119:26
[X] Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
[X] Make sure this is a Vite issue and not a framework-specific issue. For example, if it's a Vue SFC related bug, it should likely be reported to vuejs/core instead.
Hello @burakfircasiguzel. Please provide a minimal reproduction using a GitHub repository or StackBlitz. Issues marked with need reproduction will be closed if they have no activity within 3 days.
Describe the bug
I want to use jsPDF library on React JS. I added the library with 'npm i jspdf' Then I imported jsPDF like this => import { jsPDF } from "jspdf";
In this way, I can get PDF outputs. So far, no problem. However, when I want to build with Vite, I get this error.
Could not resolve '../internals/define-globalThis-property' from ../internals/define-globalThis-property?commonjs-external error during build: Error: Could not resolve '../internals/define-globalThis-property' from ../internals/define-globalThis-property?commonjs-external at error (file:///C:/Users/BurakFircasig%C3%BCzel/Documents/react-projects/bf-v02-generator/node_modules/rollup/dist/es/shared/rollup.js:1858:30) at ModuleLoader.handleResolveId (file:///C:/Users/BurakFircasig%C3%BCzel/Documents/react-projects/bf-v02-generator/node_modules/rollup/dist/es/shared/rollup.js:22156:24) at file:///C:/Users/BurakFircasig%C3%BCzel/Documents/react-projects/bf-v02-generator/node_modules/rollup/dist/es/shared/rollup.js:22119:26
In this way, I can get PDF outputs. So far, no problem. However, when I want to build with Vite, I get this error.
This is my vite.config.js file.
I examined the steps one by one, I tried. import { jsPDF } from "jspdf"; If I remove it, I get the build without any problems. And of course I can't use jsPDF.
Is this issue related to Vite or jsPDF? How can I solve this problem?
Reproduction
https://www.npmjs.com/package/vite/v/3.2.4
Steps to reproduce
npm run build
System Info
Used Package Manager
npm
Logs
vite v3.2.5 building for production... ✓ 859 modules transformed. Could not resolve '../internals/define-globalThis-property' from ../internals/define-globalThis-property?commonjs-external error during build: Error: Could not resolve '../internals/define-globalThis-property' from ../internals/define-globalThis-property?commonjs-external at error (file:///C:/Users/BurakFircasig%C3%BCzel/Documents/react-projects/bf-v02-generator/node_modules/rollup/dist/es/shared/rollup.js:1858:30) at ModuleLoader.handleResolveId (file:///C:/Users/BurakFircasig%C3%BCzel/Documents/react-projects/bf-v02-generator/node_modules/rollup/dist/es/shared/rollup.js:22156:24) at file:///C:/Users/BurakFircasig%C3%BCzel/Documents/react-projects/bf-v02-generator/node_modules/rollup/dist/es/shared/rollup.js:22119:26
Validations