MrRefactoring / jira.js

A JavaScript/TypeScript wrapper for the JIRA Cloud, Service Desk and Agile REST API
https://mrrefactoring.github.io/jira.js/
MIT License
366 stars 49 forks source link

Module not found: Error: Can't resolve 'crypto' #258

Closed Coolranch closed 11 months ago

Coolranch commented 1 year ago

When adding the jira.js library to my CRA application and attempting to use the Version3Client I get the following error.

ERROR in ./node_modules/atlassian-jwt/dist/lib/jwt.js 61:15-32 Module not found: Error: Can't resolve 'crypto' in 'C:\projects\jira-helper\node_modules\atlassian-jwt\dist\lib'

BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default. This is no longer the case. Verify if you need this module and configure a polyfill for it.

If you want to include a polyfill, you need to:

Here are my package versions:

"dependencies": { "@testing-library/jest-dom": "^5.14.1", "@testing-library/react": "^13.0.0", "@testing-library/user-event": "^13.2.1", "@types/jest": "^27.0.1", "@types/node": "^16.7.13", "@types/react": "^18.0.0", "@types/react-dom": "^18.0.0", "antd": "^5.3.3", "immer": "^9.0.21", "jira.js": "^2.17.0", "react": "^18.2.0", "react-dom": "^18.2.0", "react-router-dom": "^6.9.0", "react-scripts": "5.0.1", "typescript": "^4.4.2", "use-immer": "^0.8.1", "web-vitals": "^2.1.0" }

rawat9 commented 1 year ago

Install crypto-browserify as a devDependency

npm i --save-dev crypto-browserify

Add the path to the package in your tsconfig.json

"compilerOptions": {
   ...
  "paths": {
    "crypto": ["./node_modules/crypto-browserify"]