React.js getting "Cannot find module loadash.template" error - reactjs

I created a react app using npx create-react-app myapp, and goting the following error while running npm start
Error: Cannot find module 'lodash.template'
Require stack:
- C:\Desktop\react\myapp\node_modules\workbox-build\build\lib\populate-sw-template.js
- C:\Desktop\react\myapp\node_modules\workbox-webpack-plugin\build\generate-sw.js
- C:\Desktop\react\myapp\node_modules\workbox-webpack-plugin\build\index.js
- C:\\Desktop\react\myapp\node_modules\react-scripts\config\webpack.config.js
- C:\Desktop\react\myapp\node_modules\react-scripts\scripts\start.js
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:880:15)
at Function.Module._load (internal/modules/cjs/loader.js:725:27)
at Module.require (internal/modules/cjs/loader.js:952:19)
at require (internal/modules/cjs/helpers.js:88:18)
at Object.<anonymous> (C:\Users\vanst\OneDrive\Desktop\react\myapp\node_modules\workbox-build\build\lib\populate-sw-template.js:10:18)
at Module._compile (internal/modules/cjs/loader.js:1063:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
at Module.load (internal/modules/cjs/loader.js:928:32)
at Function.Module._load (internal/modules/cjs/loader.js:769:14)
at Module.require (internal/modules/cjs/loader.js:952:19) {
code: 'MODULE_NOT_FOUND',
}
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! myapp#0.1.0 start: `react-scripts start`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the myapp#0.1.0 start 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! C:\Users\AppData\Roaming\npm-cache\_logs\2020-10-28T16_45_32_029Z-debug.log
I was able to fix this by running npm install loadash --save, but the instruction I found online seems to work fine without doing this. I reinstalled node.js, this error popped up again, I wonder what went wrong.

Try clearing cache:
npm cache clear --force

Related

web pack - Error: Cannot find module 'webpack/lib/node/NodeTemplatePlugin'

I got this error when I do npm run dev , and I have installed the latest react/react-dom globally in my pc and locally in this project.
What can be done to fix this issue?
macbookpro#MacBookProdeMacBook-Pro 01.webpack-base % npm run dev
> 01.webpack-base#1.0.0 dev /Users/macbookpro/Desktop/01.webpack-base
> webpack-dev-server --open
internal/modules/cjs/loader.js:985
throw err;
^
Error: Cannot find module 'webpack/lib/node/NodeTemplatePlugin'
Require stack:
- /Users/macbookpro/node_modules/_html-webpack-plugin#4.3.0#html-webpack-plugin/lib/child-compiler.js
- /Users/macbookpro/node_modules/_html-webpack-plugin#4.3.0#html-webpack-plugin/lib/cached-child-compiler.js
- /Users/macbookpro/node_modules/_html-webpack-plugin#4.3.0#html-webpack-plugin/index.js
- /Users/macbookpro/Desktop/01.webpack-base/webpack.config.js
- /usr/local/lib/node_modules/webpack-cli/bin/utils/convert-argv.js
- /usr/local/lib/node_modules/webpack-dev-server/bin/webpack-dev-server.js
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:982:15)
at Function.Module._load (internal/modules/cjs/loader.js:864:27)
at Module.require (internal/modules/cjs/loader.js:1044:19)
at require (internal/modules/cjs/helpers.js:77:18)
at Object.<anonymous> (/Users/macbookpro/node_modules/_html-webpack-plugin#4.3.0#html-webpack-plugin/lib/child-compiler.js:14:28)
at Module._compile (internal/modules/cjs/loader.js:1158:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1178:10)
at Module.load (internal/modules/cjs/loader.js:1002:32)
at Function.Module._load (internal/modules/cjs/loader.js:901:14)
at Module.require (internal/modules/cjs/loader.js:1044:19) {
code: 'MODULE_NOT_FOUND',
requireStack: [
'/Users/macbookpro/node_modules/_html-webpack-plugin#4.3.0#html-webpack-plugin/lib/child-compiler.js',
'/Users/macbookpro/node_modules/_html-webpack-plugin#4.3.0#html-webpack-plugin/lib/cached-child-compiler.js',
'/Users/macbookpro/node_modules/_html-webpack-plugin#4.3.0#html-webpack-plugin/index.js',
'/Users/macbookpro/Desktop/01.webpack-base/webpack.config.js',
'/usr/local/lib/node_modules/webpack-cli/bin/utils/convert-argv.js',
'/usr/local/lib/node_modules/webpack-dev-server/bin/webpack-dev-server.js'
]
}
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! 01.webpack-base#1.0.0 dev: `webpack-dev-server --open`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the 01.webpack-base#1.0.0 dev 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! /Users/macbookpro/.npm/_logs/2020-05-27T09_15_12_766Z-debug.log
I had a similar issue this bellow helped me to fix that
rm -rf node_modules
rm package-lock.json
npm cache verify
npm install
If it does not work maybe try this taken from Raunaqss's answer :
Webpack 4 onwards you are required to install webpack-cli. You may also want to install webpack-dev-middleware if you need to use the options marked with a key on this page.
In this case the command to install is:
npm install --save-dev webpack webpack-cli html-webpack-plugin webpack-dev-server webpack-dev-middleware
As mentioned above, webpack-dev-middleware should be optionally added based on your requirements.

How to fix the error Cannot find module 'react-dev-utils/prompt'

While I was compiling the code using npm start an error occurred.
When I try to solve this issue using npm react-dev-utils nothing happens and the issue remains the same.
Here is the error log:
internal/modules/cjs/loader.js:638 throw err; ^ Error: Cannot find
module 'react-dev-utils/prompt' at Function.Module._resolveFilename
(internal/modules/cjs/loader.js:636:15) at Function.Module._load
(internal/modules/cjs/loader.js:562:25) at Module.require
(internal/modules/cjs/loader.js:690:17) at require
(internal/modules/cjs/helpers.js:25:18) at Object.
(C:\Users\cheru\smartshareapp\scripts\start.js:19:14) at
Module._compile (internal/modules/cjs/loader.js:776:30) at
Object.Module._extensions..js (internal/modules/cjs/loader.js:787:10)
at Module.load (internal/modules/cjs/loader.js:653:32) at
tryModuleLoad (internal/modules/cjs/loader.js:593:12) at
Function.Module._load (internal/modules/cjs/loader.js:585:3) npm ERR!
code ELIFECYCLE npm ERR! errno 1 npm ERR! Smartshare#0.1.0 start:
node scripts/start.js npm ERR! Exit status 1 npm ERR! npm ERR!
Failed at the Smartshare#0.1.0 start 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!
C:\Users\cheru\AppData\Roaming\npm-cache_logs\2019-06-08T08_10_21_560Z-debug.log
Can anyone help me to solve this issue?
remove the folder node_packages and rerun npm install again it should be OK!
or rerun npm install react-dev-utils --save

Cannot find module '../config/env Failed at 0.1.0 start script

it was working fine yesterday i don't know what happened npm is not starting instead giving the above error.
help me pls..
npm start scripts not working pls someone help me i'm new to this field
Husnains-Mini:~ husnaintahir$ cd ReactApp
Husnains-Mini:ReactApp husnaintahir$ cd react-complete-guide
Husnains-Mini:react-complete-guide husnaintahir$ npm start
> react-complete-guide#0.1.0 st art /Users/husnaintahir/ReactApp/react-complete-guide
> node scripts/start.js
module.js:549
throw err;
^
Error: Cannot find module '../config/env'
at Function.Module._resolveFilename (module.js:547:15)
at Function.Module._load (module.js:474:25)
at Module.require (module.js:596:17)
at require (internal/module.js:11:18)
at Object.<anonymous> (/Users/husnaintahir/ReactApp/react-complete-guide/scripts/start.js:15:1)
at Module._compile (module.js:652:30)
at Object.Module._extensions..js (module.js:663:10)
at Module.load (module.js:565:32)
at tryModuleLoad (module.js:505:12)
at Function.Module._load (module.js:497:3)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! react-complete-guide#0.1.0 start: `node scripts/start.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the react-complete-guide#0.1.0 start 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! /Users/husnaintahir/.npm/_logs/2019-05-22T04_42_05_832Z-debug.log
Husnains-Mini:react-complete-guide husnaintahir$

Angular 1 cli has multiple errors while making a new app

I've just recently installed angular 1 cli and uninstalled it, today when I installed it again I get the following errors during 'ng new' execution and I can't even build/serve it, check below this code for the build/serve errors.
> ng-core-addons#0.0.9 postinstall C:\Users\pauld\Desktop\poop\node_modules\ng-core-addons
> node ./node_modules/fs-concatenate -i content -o snippets.js
module.js:472
throw err;
^
Error: Cannot find module 'C:\Users\pauld\Desktop\poop\node_modules\ng-core-addons\node_modules\fs-concatenate'
at Function.Module._resolveFilename (module.js:470:15)
at Function.Module._load (module.js:418:25)
at Module.runMain (module.js:605:10)
at run (bootstrap_node.js:420:7)
at startup (bootstrap_node.js:139:9)
at bootstrap_node.js:535:3
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents#^1.0.0 (node_modules\chokidar\node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents#1.0.17: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
npm WARN karma-jasmine#0.3.8 requires a peer of jasmine-core#* but none was installed.
npm WARN karma-mocha-reporter#0.3.2 requires a peer of karma#>=0.9 but none was installed.
npm WARN angularApp#0.0.0 No description
npm WARN angularApp#0.0.0 No repository field.
npm WARN angularApp#0.0.0 No license field.
npm ERR! Windows_NT 10.0.14393
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install"
npm ERR! node v7.4.0
npm ERR! npm v4.0.5
npm ERR! code ELIFECYCLE
npm ERR! ng-core-addons#0.0.9 postinstall: `node ./node_modules/fs-concatenate -i content -o snippets.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the ng-core-addons#0.0.9 postinstall script 'node ./node_modules/fs-concatenate -i content -o snippets.js'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the ng-core-addons package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node ./node_modules/fs-concatenate -i content -o snippets.js
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs ng-core-addons
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls ng-core-addons
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! C:\Users\pauld\Desktop\poop\npm-debug.log
When I try to serve/build I get the following, I tried to install karma package globally but didn't work either.
I even tried installing jasmine something, didn't work.
Error: Cannot find module 'karma'
at Function.Module._resolveFilename (module.js:470:15)
at Function.Module._load (module.js:418:25)
at Module.require (module.js:498:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (C:\Users\pauld\Desktop\poop\node_modules\ngcli-task-runner\index.js:3:13)
at Module._compile (module.js:571:32)
at Object.Module._extensions..js (module.js:580:10)
at Module.load (module.js:488:32)
at tryModuleLoad (module.js:447:12)
at Function.Module._load (module.js:439:3)
[8:09:58 PM UTC] ERR! module.js:472
throw err;
^
Error: Cannot find module 'karma'
at Function.Module._resolveFilename (module.js:470:15)
at Function.Module._load (module.js:418:25)
at Module.require (module.js:498:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (C:\Users\pauld\Desktop\poop\node_modules\ngcli-task-runner\index.js:3:13)
at Module._compile (module.js:571:32)
at Object.Module._extensions..js (module.js:580:10)
at Module.load (module.js:488:32)
at tryModuleLoad (module.js:447:12)
at Function.Module._load (module.js:439:3)
×
Upgrade Angular Cli to the latest version. Update the angular-cli package installed globally in your system, using below commands:
npm uninstall -g angular-cli
npm cache clean or npm cache verify (if npm > 5)
npm install -g #angular/cli#latest
It will be fixed after the upgrade.

Error when trying to deploy node.js on Google App Engine

I am getting errors when trying to deploy Node.js app to Google App Engine. Node.js run time get crashed with require statement. What am I wrong?
Directory structure:
|--app
---protocol.js
app.js .....
In file app.js
.....
var protocol = require('./app/protocol');
....
When deploying with gcloud:
gcloud app deploy app.yaml
then errors:
> nodejs-getting-started#1.0.0 start /app
> node app.js
module.js:471
throw err;
^
Error: Cannot find module './app/protocol'
at Function.Module._resolveFilename (module.js:469:15)
at Function.Module._load (module.js:417:25)
at Module.require (module.js:497:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (/app/app.js:21:16)
at Module._compile (module.js:570:32)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
npm ERR! Linux 3.16.0-4-amd64
npm ERR! argv "/nodejs/bin/node" "/nodejs/bin/npm" "start"
npm ERR! node v6.9.2
npm ERR! npm v3.10.9
npm ERR! code ELIFECYCLE
npm ERR! nodejs-getting-started#1.0.0 start: `node app.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the nodejs-getting-started#1.0.0 start script 'node app.js'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the nodejs-getting-started package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node app.js
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs nodejs-getting-started
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls nodejs-getting-started
npm ERR! There is likely additional logging output above.
The error was reported to the google SDK issue reporting,
https://code.google.com/p/google-cloud-sdk/issues/detail?id=1431
It was solved by downgrading to 137.0.1
gcloud components update --version=137.0.1
and redoing the process.
I was having a similar issue trying to deploy a Sails.js project. Downgrading gcloud from 138.0.0 to 137.0.1 also fixed my issue.

Resources