Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

fsevents not accessible from jest-haste-map

Tags:

heroku

When i deploy my app from github.com to heroku. I get the following message error: fsevents not accessible from jest-haste-map.

Could you help me solve this issue. This is my package.json

{
  "name": "app-clean",
  "version": "0.1.0",
  "private": true,
  "main": "index.js",
  "dependencies": {
    "@reduxjs/toolkit": "^1.6.0",
    "@testing-library/jest-dom": "^5.11.4",
    "@testing-library/react": "^11.1.0",
    "@testing-library/user-event": "^12.1.10",
    "bootstrap": "^5.0.1",
    "bootstrap-icons": "^1.5.0",
    "json-server": "^0.16.3",
    "react": "^17.0.2",
    "react-dom": "^17.0.2",
    "react-redux": "^7.2.4",
    "react-scripts": "4.0.3",
    "web-vitals": "^1.0.1"
  },
  "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test",
    "eject": "react-scripts eject",
    "server": "json-server db.json -p 5000 -w -d 0"
  },
  "eslintConfig": {
    "extends": [
      "react-app",
      "react-app/jest"
    ]
  },
  "browserslist": {
    "production": [
      ">0.2%",
      "not dead",
      "not op_mini all"
    ],
    "development": [
      "last 1 chrome version",
      "last 1 firefox version",
      "last 1 safari version"
    ]
  }
}

Thanks

like image 758
Nguyễn Ngọc Hải Avatar asked Jun 17 '21 14:06

Nguyễn Ngọc Hải


Video Answer


3 Answers

I have the same issue with the GitHub Actions (is being used for style-checking and testing).

The error message appears while executing command npm ci:

fsevents not accessible from jest-haste-map

If I replace the npm ci by npm install, I receive the error about the lockfile version:

This version of npm is compatible with lockfileVersion@1, but package-lock.json was generated for lockfileVersion@2

Therefore, the reason of the issue is upgraded lockfile version to 2.

If you have the same issue, check the npm version (command) and package-lock.json (file). If the "lockfileVersion" is 2, npm must be at least 7.x.

To fix that in GitHub action I added npm-upgrading step. So, my steps looks like:

        # ...
          steps:
            # ...
            - name: Upgrade NPM
              run: npm install -g npm
            - name: Install dependencies
              run: npm ci
            - name: Build project
              run: npm run build

Thus, if you have issue like "it works on my PC, but does not work in CI/CD runner", try to use described solution.

like image 81
Toliak Avatar answered Oct 20 '22 17:10

Toliak


Try:

  1. Deleting package-lock.json and node_modules
  2. Running npm install locally, which should generate a new package-lock.json
  3. Committing and pushing the new package-lock.json

I usually try this whenever I get strange npm errors like this relating to the dependencies.

like image 38
Ruben9922 Avatar answered Oct 20 '22 18:10

Ruben9922


So it seems that there are some internal dependencies that depend on the fsevents module. The general consensus seems to be to make this dependency optional, which should fix your problem (on Windows at least).

Try:

npm i fsevents@latest -f --save-optional

That fixed the dependency issue for me.

like image 23
Ac Hybl Avatar answered Oct 20 '22 17:10

Ac Hybl