Error: Cannot find module 'graceful-fs' while installing react native - react-native

for the past couple of days now, I've been trying to install react native using npx react-native init AppName, and since then I've been getting this error. I've searched the net and couldn't get a better answer to this problem, how do i go about solving it?
node:
internal/modules/cjs/loader:959
throw err;
^
Error: Cannot find module 'graceful-fs'
Require stack:
- C:\Users\HP\AppData\Local\npm-cache\_npx\7930a8670f922cdb\node_modules\#react-native-community\cli\build\tools\gracefulifyFs.js
- C:\Users\HP\AppData\Local\npm-cache\_npx\7930a8670f922cdb\node_modules\#react-native-community\cli\build\bin.js
at Function.Module._resolveFilename (node:internal/modules/cjs/loader:956:15)
at Function.Module._load (node:internal/modules/cjs/loader:804:27)
at Module.require (node:internal/modules/cjs/loader:1028:19)
at require (node:internal/modules/cjs/helpers:102:18)
at _gracefulFs (C:\Users\HP\AppData\Local\npm-cache\_npx\7930a8670f922cdb\node_modules\#react-native-community\cli\build\tools\gracefulifyFs.js:19:39)
at Object.<anonymous> (C:\Users\HP\AppData\Local\npm-cache\_npx\7930a8670f922cdb\node_modules\#react-native-community\cli\build\tools\gracefulifyFs.js:30:1)
at Module._compile (node:internal/modules/cjs/loader:1126:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1180:10)
at Module.load (node:internal/modules/cjs/loader:1004:32)
at Function.Module._load (node:internal/modules/cjs/loader:839:12) {
code: 'MODULE_NOT_FOUND',
requireStack: [
'C:\\Users\\HP\\AppData\\Local\\npm-cache\\_npx\\7930a8670f922cdb\\node_modules\\#react-native-community\\cli\\build\\tools\\gracefulifyFs.js',
'C:\\Users\\HP\\AppData\\Local\\npm-cache\\_npx\\7930a8670f922cdb\\node_modules\\#react-native-community\\cli\\build\\bin.js'
]
}

I had the same problem.
sudo npm install
solved it for me.

Related

Unable to create vue js project with "vue create projectName" command

I try to runvue create my-project in my terminal, I've got this render :
node:internal/modules/cjs/loader:936
throw err;
^
Error: Cannot find module 'rxjs'
Require stack:
- /usr/local/lib/node_modules/#vue/cli/node_modules/inquirer/lib/ui/prompt.js
- /usr/local/lib/node_modules/#vue/cli/node_modules/inquirer/lib/inquirer.js
- /usr/local/lib/node_modules/#vue/cli/lib/create.js
- /usr/local/lib/node_modules/#vue/cli/bin/vue.js
at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)
at Function.Module._load (node:internal/modules/cjs/loader:778:27)
at Module.require (node:internal/modules/cjs/loader:1005:19)
at require (node:internal/modules/cjs/helpers:102:18)
at Object.<anonymous> (/usr/local/lib/node_modules/#vue/cli/node_modules/inquirer/lib/ui/prompt.js:7:36)
at Module._compile (node:internal/modules/cjs/loader:1105:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1159:10)
at Module.load (node:internal/modules/cjs/loader:981:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
at Module.require (node:internal/modules/cjs/loader:1005:19) {
code: 'MODULE_NOT_FOUND',
requireStack: [
'/usr/local/lib/node_modules/#vue/cli/node_modules/inquirer/lib/ui/prompt.js',
'/usr/local/lib/node_modules/#vue/cli/node_modules/inquirer/lib/inquirer.js',
'/usr/local/lib/node_modules/#vue/cli/lib/create.js',
'/usr/local/lib/node_modules/#vue/cli/bin/vue.js'
]
}
Whereas before, the command worked well!
Could someone help me to solve this problem?
Thanks in advance !

Issues when creating new react-native application

I am new to react-native programming and getting issues when creating a new react native project (npx react-native init AwesomeProject)
I have followed the steps listed here:
https://reactnative.dev/docs/environment-setup
OS: Windows | node: v16.14.2 | npm: 8.7.0 | chocolatey: 1.1.0
Error message:
C:\Users\Arvin>npx react-native init AwesomeProject
node:internal/modules/cjs/loader:936
throw err;
^
Error: Cannot find module './lib/source-map-generator'
Require stack:
- C:\Users\Arvin\AppData\Local\npm-cache\_npx\7930a8670f922cdb\node_modules\source-map\source-map.js
- C:\Users\Arvin\AppData\Local\npm-cache\_npx\7930a8670f922cdb\node_modules\#babel\generator\lib\source-map.js
- C:\Users\Arvin\AppData\Local\npm-cache\_npx\7930a8670f922cdb\node_modules\#babel\generator\lib\index.js
- C:\Users\Arvin\AppData\Local\npm-cache\_npx\7930a8670f922cdb\node_modules\#babel\traverse\lib\path\index.js
- C:\Users\Arvin\AppData\Local\npm-cache\_npx\7930a8670f922cdb\node_modules\#babel\traverse\lib\context.js
- C:\Users\Arvin\AppData\Local\npm-cache\_npx\7930a8670f922cdb\node_modules\#babel\traverse\lib\traverse-node.js
- C:\Users\Arvin\AppData\Local\npm-cache\_npx\7930a8670f922cdb\node_modules\#babel\traverse\lib\index.js
- C:\Users\Arvin\AppData\Local\npm-cache\_npx\7930a8670f922cdb\node_modules\metro-source-map\src\generateFunctionMap.js
- C:\Users\Arvin\AppData\Local\npm-cache\_npx\7930a8670f922cdb\node_modules\metro-source-map\src\source-map.js
- C:\Users\Arvin\AppData\Local\npm-cache\_npx\7930a8670f922cdb\node_modules\metro\src\DeltaBundler\Serializers\sourceMapGenerator.js
- C:\Users\Arvin\AppData\Local\npm-cache\_npx\7930a8670f922cdb\node_modules\metro\src\DeltaBundler\Serializers\sourceMapString.js
- C:\Users\Arvin\AppData\Local\npm-cache\_npx\7930a8670f922cdb\node_modules\metro\src\lib\getAppendScripts.js
- C:\Users\Arvin\AppData\Local\npm-cache\_npx\7930a8670f922cdb\node_modules\metro\src\DeltaBundler\Serializers\baseBytecodeBundle.js
- C:\Users\Arvin\AppData\Local\npm-cache\_npx\7930a8670f922cdb\node_modules\metro\src\Server.js
- C:\Users\Arvin\AppData\Local\npm-cache\_npx\7930a8670f922cdb\node_modules\metro\src\shared\output\bundle.js
- C:\Users\Arvin\AppData\Local\npm-cache\_npx\7930a8670f922cdb\node_modules\#react-native-community\cli\node_modules\#react-native-community\cli-plugin-metro\build\commands\bundle\buildBundle.js
- C:\Users\Arvin\AppData\Local\npm-cache\_npx\7930a8670f922cdb\node_modules\#react-native-community\cli\node_modules\#react-native-community\cli-plugin-metro\build\commands\bundle\bundle.js
- C:\Users\Arvin\AppData\Local\npm-cache\_npx\7930a8670f922cdb\node_modules\#react-native-community\cli\node_modules\#react-native-community\cli-plugin-metro\build\commands\bundle\index.js
- C:\Users\Arvin\AppData\Local\npm-cache\_npx\7930a8670f922cdb\node_modules\#react-native-community\cli\node_modules\#react-native-community\cli-plugin-metro\build\commands\index.js
- C:\Users\Arvin\AppData\Local\npm-cache\_npx\7930a8670f922cdb\node_modules\#react-native-community\cli\node_modules\#react-native-community\cli-plugin-metro\build\index.js
- C:\Users\Arvin\AppData\Local\npm-cache\_npx\7930a8670f922cdb\node_modules\#react-native-community\cli\build\commands\index.js
- C:\Users\Arvin\AppData\Local\npm-cache\_npx\7930a8670f922cdb\node_modules\#react-native-community\cli\build\index.js
- C:\Users\Arvin\AppData\Local\npm-cache\_npx\7930a8670f922cdb\node_modules\#react-native-community\cli\build\bin.js
at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)
at Function.Module._load (node:internal/modules/cjs/loader:778:27)
at Module.require (node:internal/modules/cjs/loader:1005:19)
at require (node:internal/modules/cjs/helpers:102:18)
at Object.<anonymous> (C:\Users\Arvin\AppData\Local\npm-cache\_npx\7930a8670f922cdb\node_modules\source-map\source-map.js:6:30)
at Module._compile (node:internal/modules/cjs/loader:1103:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1157:10)
at Module.load (node:internal/modules/cjs/loader:981:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
at Module.require (node:internal/modules/cjs/loader:1005:19) {
code: 'MODULE_NOT_FOUND',
requireStack: [
'C:\\Users\\Arvin\\AppData\\Local\\npm-cache\\_npx\\7930a8670f922cdb\\node_modules\\source-map\\source-map.js',
'C:\\Users\\Arvin\\AppData\\Local\\npm-cache\\_npx\\7930a8670f922cdb\\node_modules\\#babel\\generator\\lib\\source-map.js',
'C:\\Users\\Arvin\\AppData\\Local\\npm-cache\\_npx\\7930a8670f922cdb\\node_modules\\#babel\\generator\\lib\\index.js',
'C:\\Users\\Arvin\\AppData\\Local\\npm-cache\\_npx\\7930a8670f922cdb\\node_modules\\#babel\\traverse\\lib\\path\\index.js',
'C:\\Users\\Arvin\\AppData\\Local\\npm-cache\\_npx\\7930a8670f922cdb\\node_modules\\#babel\\traverse\\lib\\context.js',
'C:\\Users\\Arvin\\AppData\\Local\\npm-cache\\_npx\\7930a8670f922cdb\\node_modules\\#babel\\traverse\\lib\\traverse-node.js',
'C:\\Users\\Arvin\\AppData\\Local\\npm-cache\\_npx\\7930a8670f922cdb\\node_modules\\#babel\\traverse\\lib\\index.js',
'C:\\Users\\Arvin\\AppData\\Local\\npm-cache\\_npx\\7930a8670f922cdb\\node_modules\\metro-source-map\\src\\generateFunctionMap.js',
'C:\\Users\\Arvin\\AppData\\Local\\npm-cache\\_npx\\7930a8670f922cdb\\node_modules\\metro-source-map\\src\\source-map.js',
'C:\\Users\\Arvin\\AppData\\Local\\npm-cache\\_npx\\7930a8670f922cdb\\node_modules\\metro\\src\\DeltaBundler\\Serializers\\sourceMapGenerator.js',
'C:\\Users\\Arvin\\AppData\\Local\\npm-cache\\_npx\\7930a8670f922cdb\\node_modules\\metro\\src\\DeltaBundler\\Serializers\\sourceMapString.js',
'C:\\Users\\Arvin\\AppData\\Local\\npm-cache\\_npx\\7930a8670f922cdb\\node_modules\\metro\\src\\lib\\getAppendScripts.js',
'C:\\Users\\Arvin\\AppData\\Local\\npm-cache\\_npx\\7930a8670f922cdb\\node_modules\\metro\\src\\DeltaBundler\\Serializers\\baseBytecodeBundle.js',
'C:\\Users\\Arvin\\AppData\\Local\\npm-cache\\_npx\\7930a8670f922cdb\\node_modules\\metro\\src\\Server.js',
'C:\\Users\\Arvin\\AppData\\Local\\npm-cache\\_npx\\7930a8670f922cdb\\node_modules\\metro\\src\\shared\\output\\bundle.js',
'C:\\Users\\Arvin\\AppData\\Local\\npm-cache\\_npx\\7930a8670f922cdb\\node_modules\\#react-native-community\\cli\\node_modules\\#react-native-community\\cli-plugin-metro\\build\\commands\\bundle\\buildBundle.js',
'C:\\Users\\Arvin\\AppData\\Local\\npm-cache\\_npx\\7930a8670f922cdb\\node_modules\\#react-native-community\\cli\\node_modules\\#react-native-community\\cli-plugin-metro\\build\\commands\\bundle\\bundle.js',
'C:\\Users\\Arvin\\AppData\\Local\\npm-cache\\_npx\\7930a8670f922cdb\\node_modules\\#react-native-community\\cli\\node_modules\\#react-native-community\\cli-plugin-metro\\build\\commands\\bundle\\index.js',
'C:\\Users\\Arvin\\AppData\\Local\\npm-cache\\_npx\\7930a8670f922cdb\\node_modules\\#react-native-community\\cli\\node_modules\\#react-native-community\\cli-plugin-metro\\build\\commands\\index.js',
'C:\\Users\\Arvin\\AppData\\Local\\npm-cache\\_npx\\7930a8670f922cdb\\node_modules\\#react-native-community\\cli\\node_modules\\#react-native-community\\cli-plugin-metro\\build\\index.js',
'C:\\Users\\Arvin\\AppData\\Local\\npm-cache\\_npx\\7930a8670f922cdb\\node_modules\\#react-native-community\\cli\\build\\commands\\index.js',
'C:\\Users\\Arvin\\AppData\\Local\\npm-cache\\_npx\\7930a8670f922cdb\\node_modules\\#react-native-community\\cli\\build\\index.js',
'C:\\Users\\Arvin\\AppData\\Local\\npm-cache\\_npx\\7930a8670f922cdb\\node_modules\\#react-native-community\\cli\\build\\bin.js'
]
}
I have tried removing the node modules and executed 'npm install' but to no avail. Also tried the following:
npm install -g npm-check-updates
ncu -u
npm update
npm install
Your help will be greatly appreciated.
Thanks in advance.

Why npm can't find module '../../package.json' even if it already exists

The problem: when I start using npm commands I see the same error:
node:internal/modules/cjs/loader:933
const err = new Error(message);
^
Error: Cannot find module '../../package.json'
Require stack:
- C:\Users\Demian\AppData\Roaming\npm\node_modules\npm\lib\utils\unsupported.js
- C:\Users\Demian\AppData\Roaming\npm\node_modules\npm\lib\cli.js
- C:\Users\Demian\AppData\Roaming\npm\node_modules\npm\bin\npm-cli.js
at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)
at Function.Module._load (node:internal/modules/cjs/loader:778:27)
at Module.require (node:internal/modules/cjs/loader:1005:19)
at require (node:internal/modules/cjs/helpers:102:18)
at Object.<anonymous> (C:\Users\Demian\AppData\Roaming\npm\node_modules\npm\lib\utils\unsupported.js:2:19)
at Module._compile (node:internal/modules/cjs/loader:1103:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1155:10)
at Module.load (node:internal/modules/cjs/loader:981:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
at Module.require (node:internal/modules/cjs/loader:1005:19) {
code: 'MODULE_NOT_FOUND',
requireStack: [
'C:\\Users\\Demian\\AppData\\Roaming\\npm\\node_modules\\npm\\lib\\utils\\unsupported.js',
'C:\\Users\\Demian\\AppData\\Roaming\\npm\\node_modules\\npm\\lib\\cli.js',
'C:\\Users\\Demian\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js'
]
}
The same problem with npm i, -v, init and etc. The same error is when I start it from C:/user or in a project with package.json where all works before. node works correctly. What should I do?

Error: Cannot find module 'symbol-observable' in Angular

I'm getting the below error while running ng new. Tried with cmd opening as Administrator, but not helping.
D:\Training\Angular>ng new test
internal/modules/cjs/loader.js:797
throw err;
^
Error: Cannot find module 'symbol-observable'
Require stack:
- C:\Users\mubarakm\AppData\Roaming\npm\node_modules\#angular\cli\lib\init.js
- C:\Users\mubarakm\AppData\Roaming\npm\node_modules\#angular\cli\bin\ng
←[90m at Function.Module._resolveFilename (internal/modules/cjs/loader.js:794:15)←[39m
←[90m at Function.Module._load (internal/modules/cjs/loader.js:687:27)←[39m
←[90m at Module.require (internal/modules/cjs/loader.js:849:19)←[39m
←[90m at require (internal/modules/cjs/helpers.js:74:18)←[39m
at Object.<anonymous> (C:\Users\mubarakm\AppData\Roaming\npm\node_modules\←[4m#angular←[24m\cli\lib\init.js:10:1)
←[90m at Module._compile (internal/modules/cjs/loader.js:956:30)←[39m
←[90m at Object.Module._extensions..js (internal/modules/cjs/loader.js:973:10)←[39m
←[90m at Module.load (internal/modules/cjs/loader.js:812:32)←[39m
←[90m at Function.Module._load (internal/modules/cjs/loader.js:724:14)←[39m
←[90m at Module.require (internal/modules/cjs/loader.js:849:19)←[39m {
code: ←[32m'MODULE_NOT_FOUND'←[39m,
requireStack: [
←[32m'C:\\Users\\mubarakm\\AppData\\Roaming\\npm\\node_modules\\#angular\\cli\\lib\\init.js'←[39m,
←[32m'C:\\Users\\mubarakm\\AppData\\Roaming\\npm\\node_modules\\#angular\\cli\\bin\\ng'←[39m
]
}
npm i --save symbol-observable (or Yarn, then, Yarn add symbol-observable)
npm install (or Yarn)
npm outdated (or yarn outdated) to check for outdated dependencies(symbol-observable) then upgrading it to the corresonding version if needed by entering yarn upgrade symbol-observable #[version]
Else,
check if you import it correctly from
import { Observable } from 'rxjs/Observable';
to
import { Observable } from 'rxjs';
otherwise,you may have Rxjs issues as mentionned here https://github.com/angular/angular-cli/issues/4756
Simply check for any outdated dependencies using "npm outdated", and if there are any update the angular cli using command "npm update -g #angular/cli", should be good to go.

Unable to initialize an App using Expo - Following is the error shown in the terminal

internal/modules/cjs/loader.js:1088 throw err; ^
Error: Cannot find module
'C:\Users\PCNAME\AppData\Roaming\npm\node_modules\expo-c
li\bin\expo.js' ←[90m at Function.Module._resolveFilename
(internal/modules/cjs/loader.js:108 5:15)←[39m ←[90m at
Function.Module._load (internal/modules/cjs/loader.js:928:27)←[39m
←[90m at Function.executeUserEntryPoint [as runMain]
(internal/modules/run_ma in.js:60:12)←[39m ←[90m at
internal/main/run_main_module.js:17:47←[39m { code:
←[32m'MODULE_NOT_FOUND'←[39m, requireStack: [] }
Try restarting your server and simulator, or write npm install