Wednesday 28 October 2020

React and laravel mix : Cannot find module '@babel/preset-react '

I am learning unit testing using jest testing library in react js with laravel, here is what I have so far.

.babelrc file

{
    "plugins": [
      [
          "module-resolver",
          {
              "root": [
                  "./resources/js"
              ],
              "alias": {
                  "test": "./test"
              }
          }
      ]
  ],
"env": {
  "test": {
    "presets": [
      ["@babel/preset-env", {
        "targets": {
          "node": "current"
        }
      }],
      ["@babel/preset-react ", {
        "targets": {
          "node": "current"
        }
      }]
    ]
  },
  "development": {
    "presets": [
      ["env", {
        "modules": false,
        "targets": {
          "browsers": "> 2%",
          "uglify": true
        }
      }]
    ]
  },
  "production": {
    "presets": [
      ["env", {
        "modules": false,
        "targets": {
          "browsers": "> 2%",
          "uglify": true
        }
      }]
    ]
  }
}
}

package.json

{
  ............
  "devDependencies": {
    "@babel/plugin-proposal-class-properties": "^7.5.0",
    "@babel/preset-env": "^7.12.1",
    "@babel/preset-react": "^7.12.1",
    "babel-jest": "^26.6.0",
    "babel-plugin-module-resolver": "^3.2.0",
    "cross-env": "^5.2.1",
    "enzyme": "^3.11.0",
    "enzyme-adapter-react-16": "^1.15.5",
    "jest": "^26.6.0",
    "laravel-mix": "^5.0.5",
    "react-test-renderer": "^17.0.0",
    "resolve-url-loader": "^2.3.1",
    "sass": "^1.26.3",
    "sass-loader": "^7.1.0"
  }
}

Now when I run npm test I get the following error.

enter image description here

What do I need to do to solve this error?



from React and laravel mix : Cannot find module '@babel/preset-react '

No comments:

Post a Comment