Whenever I am trying to create a new react app I am facing the following error: Module.createRequire is not a function in ReactJS. We are going to Learn about All Possible Solutions So Lets Get Start with This Article.
Contents
- How Module.createRequire is not a function Error Occurs?
- How To Solve Module.createRequire is not a function Error?
- Solution 1: Use Node >= 14.0.0 and npm >= 5.6
- Summary
How Module.createRequire is not a function Error Occurs?
Whenever I am trying to create a new react app I am facing following error:
ERROR in Module.createRequire is not a function
ERROR in Error: Child compilation failed: Module.createRequire is not a function
So here I am writing all the possible solutions that I have tried to resolve this error.
How To Solve Module.createRequire is not a function Error?
- How To Solve Module.createRequire is not a function Error?
To Solve Module.createRequire is not a function Error Creating a new react app You’ll must need to have Node >= 14.0.0 and npm >= 5.6 on your machine so Just Install Node’s latest version and Also Update Your NPM. First of all, run this command to update the node: npm install -g npm Now update npm to the latest version by running this command: npm install npm@latest -g And now, your error must be solved. Thanks.
- Module.createRequire is not a function
To Solve Module.createRequire is not a function Error Creating a new react app You’ll must need to have Node >= 14.0.0 and npm >= 5.6 on your machine so Just Install Node’s latest version and Also Update Your NPM. First of all, run this command to update the node: npm install -g npm Now update npm to the latest version by running this command: npm install npm@latest -g And now, your error must be solved. Thanks.
Solution 1: Use Node >= 14.0.0 and npm >= 5.6
Creating a new react app You’ll must need to have Node >= 14.0.0 and npm >= 5.6 on your machine so Just Install Node’s latest version and Also Update Your NPM. First of all, run this command to update the node.
npm install -g npm
Now update npm to the latest version by running this command.
npm install npm@latest -g
And now, your error must be solved. Thanks.
Summary
It’s all About this error. Hope We solved Your error. Comment below Your thoughts and your queries. Also, Comment below which solution worked for you?
Also, Read
- npm ERR! code ENOLOCAL npm ERR! Could not install from “@muimaterialutils” as it does not contain a package.json file
- How to go back to previous route in react-router-dom v6?
- Error: HTTP Error: 400, Invalid JSON payload received. Unknown name “skipLog”: Cannot find field
- Matched leaf route at location “/” does not have an element
- How to downgrade React version 16 to 15?
Hello readers, Today In this article I am going to show you how to Solve – Module.createRequire is not a function Error in ReactJs. So here I will explain all the possible solutions.
Without wasting your time, Let’s start This Article to Solve This Error.
How Module.createRequire is not a function Error Occurs?
This is a common error in Python. When I am trying to create a new react app. but, I am facing following error. It looks as like below:
ERROR in Module.createRequire is not a function
ERROR in Error: Child compilation failed: Module.createRequire is not a function
So here are all the possible solutions that I tried to fix this error.
How To Solve Module.createRequire is not a function Error?
- How To Solve Module.createRequire is not a function Error?
To Solve Module.createRequire is not a function Error Creating a new react app You’ll must need to have Node >= 14.0.0 and npm >= 5.6 on your machine so Just Install Node’s latest version and Also Update Your NPM. First of all, run this command to update the node: npm install -g npm Now update npm to the latest version by running this command: npm install [email protected] -g And now, your errorwill be gone.
- Module.createRequire is not a function
To Solve Module.createRequire is not a function Error Creating a new react app You’ll must need to have Node >= 14.0.0 and npm >= 5.6 on your machine so Just Install Node’s latest version and Also Update Your NPM. First of all, run this command to update the node: npm install -g npm Now update npm to the latest version by running this command: npm install [email protected] -g And now, your errorwill be gone.
Solution 1: Use Node >= 14.0.0 and npm >= 5.6
You’ll need to have Node >= 14.0.0 and npm >= 5.6 on your machine so Just Install Node’s latest version and Also Update Your NPM. First of all, run this command to update the node.
npm install -g npm
Now update npm to the latest version by running this command.
npm install [email protected] -g
Now, your error will be gone.
Conclusion
In this article, we have discussed what causes the error and we have discussed ways to fix the error.
we hope this article has been informative. Thank you for reading. Kindly comment and let us know if you found it helpful.
16.05.2022, 15:21. Показов 743. Ответов 1
Сообщение было отмечено DrType как решение
Решение
Доброго времени суток друзья. Впервые столкнулся с такой проблемой, на локалке приложение хорошо работает компелируется, Но как переношу на vps выдает ошибку
Код
Failed to compile. Module.createRequire is not a function ERROR in Module.createRequire is not a function ERROR in Error: Child compilation failed: Module.createRequire is not a function - child-compiler.js:169 childCompiler.runAsChild [RentalShop]/[html-webpack-plugin]/lib/child-compiler.js:169:18 - Compiler.js:551 finalCallback [RentalShop]/[webpack]/lib/Compiler.js:551:5 - Compiler.js:577 compile [RentalShop]/[webpack]/lib/Compiler.js:577:11 - Compiler.js:1196 hooks.afterCompile.callAsync.err [RentalShop]/[webpack]/lib/Compiler.js:1196:17 - Hook.js:18 Hook.CALL_ASYNC_DELEGATE [as _callAsync] [RentalShop]/[tapable]/lib/Hook.js:18:14 - Compiler.js:1192 compilation.seal.err [RentalShop]/[webpack]/lib/Compiler.js:1192:33 - Compilation.js:2787 finalCallback [RentalShop]/[webpack]/lib/Compilation.js:2787:11 - Compilation.js:3092 hooks.afterSeal.callAsync.err [RentalShop]/[webpack]/lib/Compilation.js:3092:11 1 ERROR in child compilations (Use 'stats.children: true' resp. '--stats-children' for more details) webpack compiled with 3 errors
Прошу кто сталкивался отзовитесь, даже не представляю что делать, а когда запускаю npm run build выдает следующее
Код
Module.createRequire is not a function npm ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR! client@0.1.0 build: `react-scripts build` npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the client@0.1.0 build script. npm ERR! This is probably not a problem with npm. There is likely additional logging output above. npm ERR! A complete log of this run can be found in: npm ERR! /root/.npm/_logs/2022-05-16T10_40_38_390Z-debug.log
Добавлено через 1 час 40 минут
Вообщем бывает такое что после обновления пакетов node, node все равно остается старой версии! Я не знаю почему так получилось но не запускалось у меня именно из за того что как оказалось у меня старая версия node! Я ее обновил и все заработало как надо!
__________________
Помощь в написании контрольных, курсовых и дипломных работ, диссертаций здесь
0
Hi All,
I am unable to start or build the application in the course React Router 4 Basics. I have been able to successfully complete this course in the past but now I am getting errors. I am not sure what has changed.
Here is the error that I am getting in the browser …
Html Webpack Plugin:
Error: Child compilation failed:
Module.createRequire is not a function
-
child-compiler.js:169 childCompiler.runAsChild
[course-directory]/[html-webpack-plugin]/lib/child-compiler.js:169:18 -
Compiler.js:564 compile
[course-directory]/[webpack]/lib/Compiler.js:564:11 -
Compiler.js:1183 hooks.afterCompile.callAsync.err
[course-directory]/[webpack]/lib/Compiler.js:1183:17 -
Hook.js:18 Hook.CALL_ASYNC_DELEGATE [as _callAsync]
[course-directory]/[tapable]/lib/Hook.js:18:14 -
Compiler.js:1179 compilation.seal.err
[course-directory]/[webpack]/lib/Compiler.js:1179:33 -
Compilation.js:2785 finalCallback
[course-directory]/[webpack]/lib/Compilation.js:2785:11 -
Compilation.js:3090 hooks.afterSeal.callAsync.err
[course-directory]/[webpack]/lib/Compilation.js:3090:11 -
Hook.js:18 Hook.CALL_ASYNC_DELEGATE [as _callAsync]
[course-directory]/[tapable]/lib/Hook.js:18:14
And here is the error I am getting in the terminal …
Failed to compile.
Module not found: Error: Can’t resolve ‘react/lib/React’ in ‘/Users/petermingione-macbook-home/Desktop/react-router-4/1-Getting-Started-with-React-Router/3-Introducing-the-Project/course-directory/node_modules/react-dom/lib’
asset static/js/bundle.js 1.13 MiB [emitted] (name: main) 1 related asset
asset index.html 1.03 KiB [emitted]
asset asset-manifest.json 190 bytes [emitted]
runtime modules 28.2 KiB 13 modules
modules by path ./node_modules/ 973 KiB 249 modules
modules by path ./src/ 16.9 KiB
modules by path ./src/css/*.css 13.8 KiB
./src/css/index.css 2.77 KiB [built] [code generated]
./node_modules/css-loader/dist/cjs.js??ruleSet[1].rules[1].oneOf[5].use[1]!./node_modules/postcss-loader/dist/cjs.js??ruleSet[1].rules[1].oneOf[5].use[2]!./node_modules/source-map-loader/dist/cjs.js!./src/css/index.css 11 KiB [built] [code generated]
./src/index.js 1.58 KiB [built] [code generated]
./src/components/App.js 1.55 KiB [built] [code generated]
ERROR in ./node_modules/react-dom/lib/LinkedValueUtils.js 16:12-38
Module not found: Error: Can’t resolve ‘react/lib/React’ in ‘/Users/petermingione-macbook-home/Desktop/react-router-4/1-Getting-Started-with-React-Router/3-Introducing-the-Project/course-directory/node_modules/react-dom/lib’
@ ./node_modules/react-dom/lib/ReactDOMTextarea.js 13:23-52
@ ./node_modules/react-dom/lib/ReactDOMComponent.js 43:23-52
@ ./node_modules/react-dom/lib/ReactDefaultInjection.js 24:24-54
@ ./node_modules/react-dom/lib/ReactDOM.js 14:28-62
@ ./node_modules/react-dom/index.js 3:0-42
@ ./src/index.js 5:0-33 9:0-15
ERROR in ./node_modules/react-dom/lib/ReactChildReconciler.js 39:31-74
Module not found: Error: Can’t resolve ‘react/lib/ReactComponentTreeHook’ in ‘/Users/petermingione-macbook-home/Desktop/react-router-4/1-Getting-Started-with-React-Router/3-Introducing-the-Project/course-directory/node_modules/react-dom/lib’
@ ./node_modules/react-dom/lib/ReactMultiChild.js 22:27-60
@ ./node_modules/react-dom/lib/ReactDOMComponent.js 47:22-50
@ ./node_modules/react-dom/lib/ReactDefaultInjection.js 24:24-54
@ ./node_modules/react-dom/lib/ReactDOM.js 14:28-62
@ ./node_modules/react-dom/index.js 3:0-42
@ ./src/index.js 5:0-33 9:0-15
ERROR in ./node_modules/react-dom/lib/ReactCompositeComponent.js 13:12-38
Module not found: Error: Can’t resolve ‘react/lib/React’ in ‘/Users/petermingione-macbook-home/Desktop/react-router-4/1-Getting-Started-with-React-Router/3-Introducing-the-Project/course-directory/node_modules/react-dom/lib’
@ ./node_modules/react-dom/lib/instantiateReactComponent.js 13:30-66
@ ./node_modules/react-dom/lib/ReactMount.js 44:32-70
@ ./node_modules/react-dom/lib/ReactDOM.js 16:17-40
@ ./node_modules/react-dom/index.js 3:0-42
@ ./src/index.js 5:0-33 9:0-15
ERROR in ./node_modules/react-dom/lib/ReactCompositeComponent.js 17:24-62
Module not found: Error: Can’t resolve ‘react/lib/ReactCurrentOwner’ in ‘/Users/petermingione-macbook-home/Desktop/react-router-4/1-Getting-Started-with-React-Router/3-Introducing-the-Project/course-directory/node_modules/react-dom/lib’
@ ./node_modules/react-dom/lib/instantiateReactComponent.js 13:30-66
@ ./node_modules/react-dom/lib/ReactMount.js 44:32-70
@ ./node_modules/react-dom/lib/ReactDOM.js 16:17-40
@ ./node_modules/react-dom/index.js 3:0-42
@ ./src/index.js 5:0-33 9:0-15
ERROR in ./node_modules/react-dom/lib/ReactDOMInvalidARIAHook.js 12:29-72
Module not found: Error: Can’t resolve ‘react/lib/ReactComponentTreeHook’ in ‘/Users/petermingione-macbook-home/Desktop/react-router-4/1-Getting-Started-with-React-Router/3-Introducing-the-Project/course-directory/node_modules/react-dom/lib’
@ ./node_modules/react-dom/lib/ReactDOM.js 109:32-68
@ ./node_modules/react-dom/index.js 3:0-42
@ ./src/index.js 5:0-33 9:0-15
ERROR in ./node_modules/react-dom/lib/ReactDOMNullInputValuePropHook.js 10:29-72
Module not found: Error: Can’t resolve ‘react/lib/ReactComponentTreeHook’ in ‘/Users/petermingione-macbook-home/Desktop/react-router-4/1-Getting-Started-with-React-Router/3-Introducing-the-Project/course-directory/node_modules/react-dom/lib’
@ ./node_modules/react-dom/lib/ReactDOM.js 107:39-82
@ ./node_modules/react-dom/index.js 3:0-42
@ ./src/index.js 5:0-33 9:0-15
ERROR in ./node_modules/react-dom/lib/ReactDOMOption.js 12:12-38
Module not found: Error: Can’t resolve ‘react/lib/React’ in ‘/Users/petermingione-macbook-home/Desktop/react-router-4/1-Getting-Started-with-React-Router/3-Introducing-the-Project/course-directory/node_modules/react-dom/lib’
@ ./node_modules/react-dom/lib/ReactDOMComponent.js 39:21-48
@ ./node_modules/react-dom/lib/ReactDefaultInjection.js 24:24-54
@ ./node_modules/react-dom/lib/ReactDOM.js 14:28-62
@ ./node_modules/react-dom/index.js 3:0-42
@ ./src/index.js 5:0-33 9:0-15
ERROR in ./node_modules/react-dom/lib/ReactDOMUnknownPropertyHook.js 14:29-72
Module not found: Error: Can’t resolve ‘react/lib/ReactComponentTreeHook’ in ‘/Users/petermingione-macbook-home/Desktop/react-router-4/1-Getting-Started-with-React-Router/3-Introducing-the-Project/course-directory/node_modules/react-dom/lib’
@ ./node_modules/react-dom/lib/ReactDOM.js 105:36-76
@ ./node_modules/react-dom/index.js 3:0-42
@ ./src/index.js 5:0-33 9:0-15
ERROR in ./node_modules/react-dom/lib/ReactDebugTool.js 15:29-72
Module not found: Error: Can’t resolve ‘react/lib/ReactComponentTreeHook’ in ‘/Users/petermingione-macbook-home/Desktop/react-router-4/1-Getting-Started-with-React-Router/3-Introducing-the-Project/course-directory/node_modules/react-dom/lib’
@ ./node_modules/react-dom/lib/ReactInstrumentation.js 14:23-50
@ ./node_modules/react-dom/lib/ReactDOM.js 103:29-62
@ ./node_modules/react-dom/index.js 3:0-42
@ ./src/index.js 5:0-33 9:0-15
ERROR in ./node_modules/react-dom/lib/ReactMount.js 16:12-38
Module not found: Error: Can’t resolve ‘react/lib/React’ in ‘/Users/petermingione-macbook-home/Desktop/react-router-4/1-Getting-Started-with-React-Router/3-Introducing-the-Project/course-directory/node_modules/react-dom/lib’
@ ./node_modules/react-dom/lib/ReactDOM.js 16:17-40
@ ./node_modules/react-dom/index.js 3:0-42
@ ./src/index.js 5:0-33 9:0-15
ERROR in ./node_modules/react-dom/lib/ReactMount.js 20:24-62
Module not found: Error: Can’t resolve ‘react/lib/ReactCurrentOwner’ in ‘/Users/petermingione-macbook-home/Desktop/react-router-4/1-Getting-Started-with-React-Router/3-Introducing-the-Project/course-directory/node_modules/react-dom/lib’
@ ./node_modules/react-dom/lib/ReactDOM.js 16:17-40
@ ./node_modules/react-dom/index.js 3:0-42
@ ./src/index.js 5:0-33 9:0-15
ERROR in ./node_modules/react-dom/lib/ReactMultiChild.js 18:24-62
Module not found: Error: Can’t resolve ‘react/lib/ReactCurrentOwner’ in ‘/Users/petermingione-macbook-home/Desktop/react-router-4/1-Getting-Started-with-React-Router/3-Introducing-the-Project/course-directory/node_modules/react-dom/lib’
@ ./node_modules/react-dom/lib/ReactDOMComponent.js 47:22-50
@ ./node_modules/react-dom/lib/ReactDefaultInjection.js 24:24-54
@ ./node_modules/react-dom/lib/ReactDOM.js 14:28-62
@ ./node_modules/react-dom/index.js 3:0-42
@ ./src/index.js 5:0-33 9:0-15
ERROR in ./node_modules/react-dom/lib/ReactNodeTypes.js 13:12-38
Module not found: Error: Can’t resolve ‘react/lib/React’ in ‘/Users/petermingione-macbook-home/Desktop/react-router-4/1-Getting-Started-with-React-Router/3-Introducing-the-Project/course-directory/node_modules/react-dom/lib’
@ ./node_modules/react-dom/lib/getHostComponentFromComposite.js 10:21-48
@ ./node_modules/react-dom/lib/ReactDOM.js 26:36-78
@ ./node_modules/react-dom/index.js 3:0-42
@ ./src/index.js 5:0-33 9:0-15
ERROR in ./node_modules/react-dom/lib/ReactUpdateQueue.js 12:24-62
Module not found: Error: Can’t resolve ‘react/lib/ReactCurrentOwner’ in ‘/Users/petermingione-macbook-home/Desktop/react-router-4/1-Getting-Started-with-React-Router/3-Introducing-the-Project/course-directory/node_modules/react-dom/lib’
@ ./node_modules/react-dom/lib/ReactMount.js 38:23-52
@ ./node_modules/react-dom/lib/ReactDOM.js 16:17-40
@ ./node_modules/react-dom/index.js 3:0-42
@ ./src/index.js 5:0-33 9:0-15
ERROR in ./node_modules/react-dom/lib/checkReactTypeSpec.js 71:37-80
Module not found: Error: Can’t resolve ‘react/lib/ReactComponentTreeHook’ in ‘/Users/petermingione-macbook-home/Desktop/react-router-4/1-Getting-Started-with-React-Router/3-Introducing-the-Project/course-directory/node_modules/react-dom/lib’
@ ./node_modules/react-dom/lib/ReactCompositeComponent.js 30:27-58
@ ./node_modules/react-dom/lib/instantiateReactComponent.js 13:30-66
@ ./node_modules/react-dom/lib/ReactMount.js 44:32-70
@ ./node_modules/react-dom/lib/ReactDOM.js 16:17-40
@ ./node_modules/react-dom/index.js 3:0-42
@ ./src/index.js 5:0-33 9:0-15
ERROR in ./node_modules/react-dom/lib/findDOMNode.js 12:24-62
Module not found: Error: Can’t resolve ‘react/lib/ReactCurrentOwner’ in ‘/Users/petermingione-macbook-home/Desktop/react-router-4/1-Getting-Started-with-React-Router/3-Introducing-the-Project/course-directory/node_modules/react-dom/lib’
@ ./node_modules/react-dom/lib/ReactDOM.js 24:18-42
@ ./node_modules/react-dom/index.js 3:0-42
@ ./src/index.js 5:0-33 9:0-15
ERROR in ./node_modules/react-dom/lib/flattenChildren.js 43:33-76
Module not found: Error: Can’t resolve ‘react/lib/ReactComponentTreeHook’ in ‘/Users/petermingione-macbook-home/Desktop/react-router-4/1-Getting-Started-with-React-Router/3-Introducing-the-Project/course-directory/node_modules/react-dom/lib’
@ ./node_modules/react-dom/lib/ReactMultiChild.js 26:22-50
@ ./node_modules/react-dom/lib/ReactDOMComponent.js 47:22-50
@ ./node_modules/react-dom/lib/ReactDefaultInjection.js 24:24-54
@ ./node_modules/react-dom/lib/ReactDOM.js 14:28-62
@ ./node_modules/react-dom/index.js 3:0-42
@ ./src/index.js 5:0-33 9:0-15
ERROR in ./node_modules/react-dom/lib/instantiateReactComponent.js 19:21-56
Module not found: Error: Can’t resolve ‘react/lib/getNextDebugID’ in ‘/Users/petermingione-macbook-home/Desktop/react-router-4/1-Getting-Started-with-React-Router/3-Introducing-the-Project/course-directory/node_modules/react-dom/lib’
@ ./node_modules/react-dom/lib/ReactMount.js 44:32-70
@ ./node_modules/react-dom/lib/ReactDOM.js 16:17-40
@ ./node_modules/react-dom/index.js 3:0-42
@ ./src/index.js 5:0-33 9:0-15
ERROR in ./node_modules/react-dom/lib/traverseAllChildren.js 12:24-62
Module not found: Error: Can’t resolve ‘react/lib/ReactCurrentOwner’ in ‘/Users/petermingione-macbook-home/Desktop/react-router-4/1-Getting-Started-with-React-Router/3-Introducing-the-Project/course-directory/node_modules/react-dom/lib’
@ ./node_modules/react-dom/lib/flattenChildren.js 13:26-58
@ ./node_modules/react-dom/lib/ReactMultiChild.js 26:22-50
@ ./node_modules/react-dom/lib/ReactDOMComponent.js 47:22-50
@ ./node_modules/react-dom/lib/ReactDefaultInjection.js 24:24-54
@ ./node_modules/react-dom/lib/ReactDOM.js 14:28-62
@ ./node_modules/react-dom/index.js 3:0-42
@ ./src/index.js 5:0-33 9:0-15
ERROR in Module.createRequire is not a function
ERROR in Error: Child compilation failed:
Module.createRequire is not a function
-
child-compiler.js:169 childCompiler.runAsChild
[course-directory]/[html-webpack-plugin]/lib/child-compiler.js:169:18 -
Compiler.js:564 compile
[course-directory]/[webpack]/lib/Compiler.js:564:11 -
Compiler.js:1183 hooks.afterCompile.callAsync.err
[course-directory]/[webpack]/lib/Compiler.js:1183:17 -
Hook.js:18 Hook.CALL_ASYNC_DELEGATE [as _callAsync]
[course-directory]/[tapable]/lib/Hook.js:18:14 -
Compiler.js:1179 compilation.seal.err
[course-directory]/[webpack]/lib/Compiler.js:1179:33 -
Compilation.js:2785 finalCallback
[course-directory]/[webpack]/lib/Compilation.js:2785:11 -
Compilation.js:3090 hooks.afterSeal.callAsync.err
[course-directory]/[webpack]/lib/Compilation.js:3090:11 -
Hook.js:18 Hook.CALL_ASYNC_DELEGATE [as _callAsync]
[course-directory]/[tapable]/lib/Hook.js:18:14
1 ERROR in child compilations (Use ‘stats.children: true’ resp. ‘—stats-children’ for more details)
19 errors have detailed information that is not shown.
Use ‘stats.errorDetails: true’ resp. ‘—stats-error-details’ to show it.
webpack 5.69.1 compiled with 22 errors in 5588 ms