Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CRA 3.3.0 - webpack unknown rule #30

Open
TENsaga opened this issue Jan 16, 2020 · 26 comments
Open

CRA 3.3.0 - webpack unknown rule #30

TENsaga opened this issue Jan 16, 2020 · 26 comments
Labels
good first issue Good for newcomers help wanted Extra attention is needed

Comments

@TENsaga
Copy link

TENsaga commented Jan 16, 2020

Upgrading CRA to 3.3.0 the build stops with exception:

/mnt/c/Users/Aspen/Code/web_server/node_modules/@craco/craco/lib/plugin-utils.js:29 
    throw new Error(
    ^

Error: Found an unhandled loader in the development webpack config: /mnt/c/Users/Aspen/Code/web_server/node_modules/resolve-url-loader/index.js
 
This error probably occurred because you updated react-scripts or craco. Please try updating craco-less to the latest version:

   $ yarn upgrade craco-less

Or:

   $ npm update craco-less

If that doesn't work, craco-less needs to be fixed to support the latest version. 
Please check to see if there's already an issue in the FormAPI/craco-less repo:

   * https://github.com/FormAPI/craco-less/issues?q=is%3Aissue+webpack+unknown+rule

If not, please open an issue and we'll take a look. (Or you can send a PR!)

You might also want to look for related issues in the craco and create-react-app repos:

   * https://github.com/sharegate/craco/issues?q=is%3Aissue+webpack+unknown+rule
   * https://github.com/facebook/create-react-app/issues?q=is%3Aissue+webpack+unknown+rule

(Tried updating)

Thanks!

@tux-tn
Copy link
Collaborator

tux-tn commented Jan 31, 2020

Hello @TENsaga,
Are you using the latest version of craco-less?

@TENsaga
Copy link
Author

TENsaga commented Feb 6, 2020

Hey @tux-tn sorry about the slow response, I got this sorted out! We had to update Craco as well, we were using a pretty old version and had the wrong semver on it.

Up and running now 👍

@renleiabc
Copy link

I use the latest version,"@craco/craco": "^5.6.4", "craco-less": "^1.16.0",Why do you make such a mistake?

@zoulegeyang
Copy link

i use the latest version of @craco/craco and craco-less, but still throw this error.

@yantze
Copy link

yantze commented Jun 28, 2020

Same here when use npm:

    "@craco/craco": "^5.6.4",
    "craco-less": "^1.17.0",

yarn run build work for me.

@foreverpinetree
Copy link

I use the latest version of both, but still throw this error.
I used npm, then replaced with yarn, it works now!

@jetonk
Copy link

jetonk commented Aug 20, 2020

It happens to me as well!

`"@craco/craco": "^5.6.4",
"craco-less": "^1.17.0",

`

@cosydney
Copy link

Hey can't seem to find a workaround I'm using the latest versions and I've been deleting node modules and reinstalling with yarn but still throws the same error:

"@craco/craco": "^5.7.0", "craco-less": "^1.17.0",

@ndbroadbent
Copy link
Member

Hey sorry everyone, it looks like there have been some changes and we will need to make some updates. Are there any talented developers in here who would have some free time to look this issue and submit a PR? We would be really grateful for any help!

@ndbroadbent ndbroadbent reopened this Oct 18, 2020
@ndbroadbent
Copy link
Member

ndbroadbent commented Oct 18, 2020

Hacktoberfest is still running, so this could be a great opportunity to get a free T-shirt or plant a tree.

@davidshare
Copy link

So this error occurs when I run export NODE_ENV=production

@iamrakhmatov
Copy link

Hi, I got the same error after deployment to Heroku in dev mode everything works fine but in prod getting this error:

Starting process with command npm start
tantal@0.1.0 start /app
craco start

(node:28) UnhandledPromiseRejectionWarning: Error: Found an unhandled loader in the production webpack config: /app/node_modules/style-loader/dist/cjs.js

This error probably occurred because you updated react-scripts or craco. Please try updating craco-less to the latest version:
$ yarn upgrade craco-less
Or:
$ npm update craco-less

If that doesn't work, craco-less needs to be fixed to support the latest version.


deleted package-lock.json and node_modules and installed everything with yarn

"@craco/craco": "^6.1.1",
"craco-less": "^1.17.1",
"react-scripts": "4.0.1",

Need some help pls!!

@AsmaDhanePersonal
Copy link

Any news about this issue? I've got the same problem when I set my ENV_NODE to production but works fine in development mode. Any ideas about the possible fixes?

@lorance19
Copy link

Still having this error.

@simibac
Copy link

simibac commented May 26, 2021

Also still have this error.

@protogenesis
Copy link

protogenesis commented Aug 18, 2021

So that's how I solved the issue.

Set your NODE_ENV environment variable to development and restart the project, and the error will disappear.

To set an environment variable in Windows:

SET NODE_ENV=development

on OS X or Linux:

export NODE_ENV=development

You should be able to see this by typing node in the command prompt which will open the node shell and then type process.env.NODE_ENV.

Ref:

https://githubmemory.com/repo/DocSpring/craco-less/issues/51
https://stackoverflow.com/questions/11104028/why-is-process-env-node-env-undefined

@Envov
Copy link

Envov commented Nov 7, 2021

this is my package.json

{
  "name": "ts-hooks",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "craco-alias": "^3.0.1",
    "@craco/craco": "^6.2.0",
    "@jiaminghi/data-view-react": "^1.2.5",
    "@tailwindcss/postcss7-compat": "^2.2.7",
    "@types/jquery": "^3.5.6",
    "@types/node": "^12.0.0",
    "@types/ramda": "^0.27.44",
    "@types/react": "^17.0.0",
    "@types/react-dom": "^17.0.0",
    "@types/react-redux": "^7.1.18",
    "@types/react-router-dom": "^5.1.8",
    "antd": "^4.16.10",
    "autoprefixer": "^9",
    "craco-less": "^1.20.0",
    "echarts": "^5.1.2",
    "js-export-excel": "^1.1.4",
    "moment": "^2.25.3",
    "postcss": "^7",
    "ramda": "^0.27.1",
    "react": "^17.0.2",
    "react-dom": "^17.0.2",
    "react-redux": "^7.2.4",
    "react-router-dom": "^5.2.0",
    "react-scripts": "4.0.3",
    "redux": "^4.1.1",
    "tailwindcss": "npm:@tailwindcss/postcss7-compat",
    "typescript": "^4.1.2",
    "use-screenfull": "^0.0.4",
    "web-vitals": "^1.0.1"
  },
  "scripts": {
    "serve": "craco start",
    "start": "craco start",
    "build": "craco build"
  },
  "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"
    ]
  }
}

this error was also throwed.

@bulletbrand
Copy link

Still actual problem, when I try run me application with concurently and with ENV I get this issue

@OlyLis1005
Copy link

OlyLis1005 commented Nov 23, 2021

I try everything not work😢
1.downgrad my dependencies to craco-less@1.16.0 and @craco/craco@5.6.4
2.set NODE_ENV=development through cross-env in scripts
3.upgrade craco-less and craco/craco to latest version
4.remove nodemodules and use yarn to reinstall my package

this is my packge.json

{
  "name": "react-template",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "@ant-design/icons": "^4.7.0",
    "@craco/craco": "^6.4.0",
    "@testing-library/jest-dom": "^5.15.0",
    "@testing-library/react": "^11.2.7",
    "@testing-library/user-event": "^12.8.3",
    "@types/jest": "^26.0.24",
    "@types/node": "^12.20.37",
    "@types/react": "^17.0.34",
    "@types/react-dom": "^17.0.11",
    "antd": "^4.16.13",
    "axios": "^0.24.0",
    "craco-less": "^1.20.0",
    "jsurl": "^0.1.5",
    "node-sass": "^6.0.1",
    "react": "^17.0.2",
    "react-dom": "^17.0.2",
    "react-redux": "^7.2.6",
    "react-router-dom": "^6.0.2",
    "react-scripts": "^4.0.3",
    "typescript": "^4.4.4",
    "web-vitals": "^1.1.2"
  },
  "scripts": {
    "start": "cross-env NODE_ENV=development craco start",
    "build": "craco build",
    "test": "craco test",
    "eject": "react-scripts eject",
    "start-old": "react-scripts start",
    "build-old": "react-scripts build",
    "test-old": "react-scripts test",
    "start-by-rewired": "react-app-rewired start"
  },
  "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"
    ]
  },
  "devDependencies": {
    "@babel/core": "^7.16.0",
    "@types/jsurl": "^1.2.30",
    "cross-env": "^7.0.3",
    "less-loader": "^10.2.0"
  }
}

and my craco.config.js

const CracoLessPlugin = require('craco-less')

module.exports = {
  plugins: [
    {
      plugin: CracoLessPlugin,
      options: {
        lessLoaderOptions: {
          lessOptions: {
            modifyVars: {
              '@primary-color': '#eb6700',
              '@link-color': '#eb6700',
            },
            javascriptEnabled: true,
          },
        },
      },
    },
  ],
}

@gallen-1240
Copy link

Do you have a solution, brother

@zdkhero
Copy link

zdkhero commented Dec 22, 2021

I also encountered the same problem and used the following methods. Fortunately, I solved this problem

  1. delete node_modules
  2. yarn upgrade craco-less
  3. yarn

Good luck ~~~

@kai-phan
Copy link

Just downgrade react-scripts to 4.0.3 everything work fine

@fourpastmidnight
Copy link
Contributor

I ran into this issue and reported as #98. I submitted PR #99 which fixes this error. To be clear, I'm using @craco/craco:6.4.3 (latest supported version, but it also would work with v6.1.2, the version I was using prior) and react-scripts@4.0.3. I suspect this would work for just about anything, as it seems to be the way craco-less is trying to search for loaders that is the issue.

Please let me know if #99 resolves this for you all, and if so, maybe we can get the maintainer to get it merged.

@FathimaOB01
Copy link

FathimaOB01 commented Jun 5, 2022

You can try following these steps,

  1. Remove nodemodules
  2. Remove yarn.lock/package-lock file
  3. Add this to package.json file
  "resolutions": {
    "//": "See https://github.com/facebook/create-react-app/issues/11773",
    "react-error-overlay": "6.0.9"
  }
  1. yarn add
  2. yarn add -D react-error-overlay@6.0.9
  3. yarn start

Note: I am using "react": "^17.0.1"

This worked for me!

@228432
Copy link

228432 commented Jun 20, 2023

请把 @craco/caraco 和 craco-less 都使用最新版本
升级完还不可以 就删除 node_modules
再使用yarn来重新下载依赖
不要使用npm 或 cnpm 会出现问题

@228432
Copy link

228432 commented Jun 20, 2023

Please use the latest version of both @craco/caraco and craco-less
Delete node_modules if the upgrade is still not working
Then use yarn to re-download dependencies
Don't use npm or cnpm there will be problems

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests