Objective:
Setup an development environment to create PDF generation using PDFKit
Problem faced
The version node 18 and react 18 has some lagency issues that prevented pdfkit to function properly.
Solution:
Recreate the environment using lower version of react and node.
these are the working version of dependancies and react version
{
"name": "pdfkit-react-example",
"version": "0.1.0",
"private": true,
"homepage": "http://sturtevant.github.io/pdfkit-react-example",
"dependencies": {
"@testing-library/jest-dom": "^4.2.4",
"@testing-library/react": "^9.5.0",
"@testing-library/user-event": "^7.2.1",
"ace-builds": "^1.4.12",
"blob-stream": "^0.1.3",
"brace": "^0.11.1",
"node-sass": "^7.0.1",
"pdfkit": "^0.10.0",
"react": "^16.13.1",
"react-ace": "^9.1.1",
"react-dom": "^16.13.1",
"react-scripts": "3.4.1"
},
"devDependencies": {
"arraybuffer-loader": "^1.0.8",
"brfs": "^2.0.2",
"customize-cra": "^1.0.0",
"gh-pages": "^3.1.0",
"html-webpack-plugin": "^3.2.0",
"raw-loader": "^3.1.0",
"react-app-rewired": "^2.1.6",
"string-replace-webpack-plugin": "^0.1.3",
"transform-loader": "^0.2.4",
"webpack": "^4.41.2",
"webpack-cli": "^3.3.10"
},
"scripts": {
"start": "react-app-rewired start",
"build": "react-app-rewired build",
"test": "react-app-rewired test",
"predeploy": "npm run build",
"deploy": "gh-pages -d build"
},
"eslintConfig": {
"extends": "react-app"
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
}
}
Problem faced: Unable to downgrade node version
Solution: In order to downgrade the node version:
Use nvm, available for download from: https://github.com/nvm-sh/nvm
Downgrading Node
After installing n, enter the following command to downgrade to any version of Node:
n
For example, running n 10.24.0 will install Node version 10.24.0.
For Windows and nvm, the command is:
nvm install
After installation, run nvm use