The event in which npx create-react-app Error occurred - node.js

I keep getting errors when I do npx create-react-app. Please help me!!!!!!!!!!!!!
I tried yarn create react-app, but the result was the same.
Please let me know how I can solve this problem.
Error: Cannot find module 'C:\Users\me\React_projects\react-basic\test\node_modules\fs-extra\lib\index.js'. Please verify that the package.json has a valid "main" entry
at tryPackage (internal/modules/cjs/loader.js:303:19)
at Function.Module._findPath (internal/modules/cjs/loader.js:516:18)
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:867:27)
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\me\React_projects\react-basic\test\node_modules\react-scripts\scripts\init.js:17:12)
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) {
code: 'MODULE_NOT_FOUND',
path: 'C:\\Users\\me\\React_projects\\react-basic\\test\\node_modules\\fs-extra\\package.json',
requestPath: 'fs-extra'
}
Aborting installation.
node has failed.
Deleting generated file... node_modules
Deleting generated file... package.json
Deleting generated file... yarn.lock
Deleting test/ from C:\Users\me\React_projects\react-basic
Done.

Solutions 1:
This issue related maybe to node module, path is updated and not targeted to index.js, so that its cant be load, or its happen since you have more than dirctory with the same file name...
any way, to resolve this issue, try to do this:
Remove package-lock.json
Remove node_modules
Then install it again
Then start
if you do this, you will remove old module and lock packagest and install it like a first install
==================
Solutions 2:
if prev steps not work, please make sure to test run via node direct, for example, get a copy for your project to desktop and try to install it and run it direct via node index.js and look what will be happen...
==================
Solutions 3:
check your package.json and make sure the npm start is call a truth file-name / file-path which its exists...like "dev": "...../myProject/app.js" (its package.json in above level of app.js...
==================
Solutions 4:
make sure your node and npm/yarn its install globally and its can be accessed every where...via node -v for example...
==================
Solutions 5:
make sure theirs no suffix empty space in file name or directory name
====================
for me, usually solution 1 or 3 or 5 resolve issue most time for our team issue like this...
I wish one of these solution is work for you...

Related

React MODULE_NOT_FOUND error even if it should be correct

recently I've been working with react. I had 4 days free and took a rest. Soon as I started again and tried to npm start it displayed error in terminal. Before that I cleared my desktop because it had a lot of folders and I moved that project in other folder. I thought that that might somehow cause the error and I've just tried with new npx create-react-app my-app. However this didn't fix error. It displays it on every single react project I have. I've been googling for 2 hours and tried everything although it didn't work. Can somebody please help.
Error:
The system cannot find the path specified.
node:internal/modules/cjs/loader:936
throw err;
Error: Cannot find module 'C:\Users\nijaz\Desktop\react-scripts\bin\react-scripts.js'
at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)
at Function.Module._load (node:internal/modules/cjs/loader:778:27)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:77:12)
at node:internal/main/run_main_module:17:47 {
code: 'MODULE_NOT_FOUND',
requireStack: []
}
Thank you for your time.
I found what was problem for me. Actually my folder structure was going like this:
Web Dev & Programming => Udemy ReacJS => -First React Big Project => senbonzakura-food
And this "&" in the "Web Dev & Progamming" was making the probelm.
Just Delete the node_modules directory, Delete the package-lock.json file and Run npm install, Run npm start.
try this:
rm -rf node_modules package-lock.json
Also: You Just need to make Sure that right address path for app.js (it should be app.js, main.js, start.js, server.js, or whatever you picked up) in out Package.json file.
{"npm": .js}
good luck 🤝

Why does npm start give me "Error: Cannot find module './keywords'"?

Tried to use npm start with Create React App to launch my react application, but got this error:
node:internal/modules/cjs/loader:943
throw err;
^
Error: Cannot find module './keywords'
Require stack:
- D:\social-ribbon\node_modules\ajv-keywords\index.js
- D:\social-ribbon\node_modules\webpack\node_modules\schema-utils\src\validateOptions.js
- D:\social-ribbon\node_modules\webpack\node_modules\schema-utils\src\index.js
- D:\social-ribbon\node_modules\webpack\lib\SourceMapDevToolPlugin.js
- D:\social-ribbon\node_modules\webpack\lib\WebpackOptionsApply.js
- D:\social-ribbon\node_modules\webpack\lib\webpack.js
- D:\social-ribbon\node_modules\react-scripts\scripts\start.js
at Function.Module._resolveFilename (node:internal/modules/cjs/loader:940:15)
at Function.Module._load (node:internal/modules/cjs/loader:773:27)
at Module.require (node:internal/modules/cjs/loader:1012:19)
at require (node:internal/modules/cjs/helpers:93:18)
at Object.<anonymous> (D:\social-ribbon\node_modules\ajv-keywords\index.js:3:16)
at Module._compile (node:internal/modules/cjs/loader:1108:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1137:10)
at Module.load (node:internal/modules/cjs/loader:988:32)
at Function.Module._load (node:internal/modules/cjs/loader:828:14)
at Module.require (node:internal/modules/cjs/loader:1012:19) {
requireStack: [
'D:\\social-ribbon\\node_modules\\ajv-keywords\\index.js',
'D:\\social-ribbon\\node_modules\\webpack\\node_modules\\schema-utils\\src\\validateOptions.js',
'D:\\social-ribbon\\node_modules\\webpack\\node_modules\\schema-utils\\src\\index.js',
'D:\\social-ribbon\\node_modules\\webpack\\lib\\SourceMapDevToolPlugin.js',
'D:\\social-ribbon\\node_modules\\webpack\\lib\\WebpackOptionsApply.js',
'D:\\social-ribbon\\node_modules\\webpack\\lib\\webpack.js',
'D:\\social-ribbon\\node_modules\\react-scripts\\scripts\\start.js'
]
}
Someone suggested searching for a file called "keywords", but that word only appears in files as part of ajv-keywords or css-color-keywords. Someone else advised reinstalling the entire node-modules folder, but that sounds a bit drastic. I'm now asking you for help. Thanks for any help.
I also faced the same problem. What I did was removed the node modules folder and reinstalled it. I will also share the commands
rm -R node_modules
npm cache --force clean
npm cache --force clear
npm install
npm start
Hope this works. It worked form me, but in my case, there was a folder of avj-keywords.
Assuming you import it as "Keywords",
Change import Keywords from './keywords' to import Keywords from 'keywords'
You don't need to use relative paths when importing packages from node_modules.

Can I use a custom node_modules path with create-react-app

I'm working on a project inside a VM (really docker on windows via vscode remote-containers). I would like to avoid building my react app at $(pwd)/node_modules, because everything under $(pwd) is synced to my windows file system which causes serious performance issues.
I'm fairly new to nodejs in general, but I'm surprised how difficult this seems to figure out.
I successfully started with this:
yarn --modules-folder /tmp/vendor
This gave me a /tmp/vendor folder with expected dependencies listed.
For the next step, I want to run the development server, so I run this:
yarn --modules-folder /tmp/vendor start
I get /bin/sh: react-scripts: command not found. I figure yarns --modules-folder doesn't reconfigure PATH information when running commands (yarn start calls react-scripts start). So I just added my own PATH as a workaround:
PATH=$PATH:/tmp/vendor/.bin/ yarn --modules-folder /tmp/vendor start
But now I get this:
[root#352b76226b83 owio]# PATH=$PATH:/tmp/vendor/.bin/ yarn --modules-folder /tmp/vendor start
yarn run v1.22.5
$ react-scripts start
internal/modules/cjs/loader.js:965
throw err;
^
Error: Cannot find module 'react-dev-utils/crossSpawn'
Require stack:
- /tmp/vendor/react-scripts/bin/react-scripts.js
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:962:15)
at Function.Module._load (internal/modules/cjs/loader.js:838:27)
at Module.require (internal/modules/cjs/loader.js:1022:19)
at require (internal/modules/cjs/helpers.js:72:18)
at Object.<anonymous> (/tmp/vendor/react-scripts/bin/react-scripts.js:18:15)
at Module._compile (internal/modules/cjs/loader.js:1118:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1138:10)
at Module.load (internal/modules/cjs/loader.js:982:32)
at Function.Module._load (internal/modules/cjs/loader.js:875:14)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12) {
code: 'MODULE_NOT_FOUND',
requireStack: [ '/tmp/vendor/react-scripts/bin/react-scripts.js' ]
}
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command
Since it is complaining about missing modules, I also set the NODE_PATH (I guess yarn doesn't forward this variable either):
NODE_PATH=/tmp/vendor PATH=$PATH:/tmp/vendor/.bin/ yarn --modules-folder /tmp/vendor start
With this, I get:
./src/index.jsx
Line 0: Parsing error: Cannot find module 'eslint-scope' from '/tmp/vendor/eslint/lib/api.js'
I'm stuck here, because eslint-scope does exist, and I've already what I can to work around path problems.
I'm half tempted to start trying other tools outside of CRA and yarn but I don't really know the ecosystem well enough yet to understand how to port my application over. Any advice would be greatly appreciated.
EDIT:
I've gotten closer by changing vendor to node_modules. I guess this convention is somehow necessary. I also added NODE_PATH=/tmp/node_modules to a .env file, and the --modules-folder /tmp/node_modules to a .yarnrc file.
EDIT 2:
I made a symlink for $(pwd)/node_modules -> /tmp/node_modules as suggested and this seems to have worked this time around, given that I added the NODE_PATH to .env.
It seems all the react-script stuff is working now, but when compiling the local source files under src/components/, I get errors about not resolving modules from /tmp/node_modules that do indeed exist.
After some tinkering and support from Estus, I found that having the following things works for me:
.env file with NODE_PATH=/tmp/node_modules
.yarnrc file with --modules-folder /tmp/node_modules
symlink for $(pwd)/node_modules -> /tmp/node_modules
I'm not sure why the symlink is necessary, and would love to know if anyone has a .env like solution. It seems my local source files are compiled against this folder regardless of having NODE_PATH set.
Other oddities I don't understand, but maybe someone will:
I could not just have NODE_PATH as a variable in my yarn command. It seems having the value in .env changed how modules within node_modules were compiled.
I could not use a name other than node_modules. No idea why.
As an aside:
For anyone landing here having the same issue (slow docker performance on windows or mac), you may need to make sure you're editor is not indexing node_modules. For example, I have set files.watcherExclude in my .vscode/settings.json to include "**/node_modules": true,".

Can't run node module geojson-polygon-labels on Windows

I've download the package from "https://github.com/andrewharvey/geojson-polygon-labels/", ran "npm-install" and the node-modules folder was successfully created:
folder - screenshot
However, when cd to bin folder and run "geojson-polygon-labels < v.geojson > v_label.geojson", it throws the eror: "not recognized as internal or external command, operable program or batch file".
I'm really confused at this point. On github it's not really well-documented how to use this tool, and I'm quite new to Node too.
Please help me. Thanks!
Edit: I've tried install it on Ubuntu (subsystem on Windows 10) then run "geojson-polygon-labels" from the bin folder. The same error occured.
Edit2: I figured out to how properly run the tool. On Ubuntu I ran:
./geojson-polygon-labels < polygon.geojson > labels.geojson
However, now a new error pops out:
/home/lamnguyen/geojson-polygon-labels-master/bin/geojson-polygon-labels:25
turf.featureEach(flatInputGeoJSON, (feature) => {
^
SyntaxError: Unexpected token >
at Module._compile (module.js:439:25)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Function.Module.runMain (module.js:497:10)
at startup (node.js:119:16)
at node.js:902:3
What should I do now?
Edit 4: A friend of mine ran it on a "real" Ubuntu with a small sample file and it worked out. Maybe tomorrow I've give a shot :)
In this package I've set up the bin property in the package.json https://docs.npmjs.com/files/package.json#bin so when you run npm install it knows what scripts are executables. You might need to set up your PATH in your shell to the directory NPM installs the binaries to. Or use the full or relative path as you've found out.
The Unexpected Token > message seems like you're running an older version of node which doesn't support ES6 arrow functions, so try upgrading your version of node?

Cannot find module 'unicode/category/So'

When i am trying to run this command - yo mobileangularui, its showing this error. I have read many solutions on the internet but none of them removed this error. Can anyone help?
module.js:341
throw err;
^
Error: Cannot find module 'unicode/category/So'
at Function.Module._resolveFilename (module.js:339:15)
at Function.Module._load (module.js:290:25)
at Module.require (module.js:367:17)
at require (internal/module.js:20:19)
at symbols (/usr/lib/node_modules/generator-mobileangularui/node_modules/slug/slug.js:6:16)
at /usr/lib/node_modules/generator-mobileangularui/node_modules/slug/slug.js:123:5
at Object.<anonymous> (/usr/lib/node_modules/generator-mobileangularui/node_modules/slug/slug.js:130:2)
There is, sometimes, an issue with npm and executing post install script. Try this steps :
cd /path/to/your/project/node_modules/unicode
check emptiness category directory with ls command
execute this command npm test
If the test is ok, you can continue your work. If it doesn't work check this issue on GitHub.
Hope it help and sorry for my English.
If you are facing this issue and you are behind windows please follow below steps, I hope worked for you :
Remove the unicode module using npm, npm remove unicode
Download the file from
http://unicode.org/Public/UNIDATA/UnicodeData.txt and placed it into
C:\usr\share\unicode-data\ if your project is in C drive, or if you are in
linux /usr/share/unicode or /usr/share/unicode-data
Install unicode again
There is a pending PR which will resolve this - https://github.com/dodo/node-unicodetable/pull/22

Resources