React: create-react-app fails with error "Cannot find module 'libnpx' - reactjs

OS-ubuntu
IDE-VS-Code
npx create-react-app was working fine,I wanted to work on a personal project when i run in to a suggestion that Create React App requires Node 14 or higher. I tried updating node using the following commands sudo npm cache clean -f and then sudo npm install -g n then i ran sudo n stable the following was installed installed : v16.13.1 (with npm 8.1.2).When i tried running npx create-react-app I got the following error
Error: Cannot find module 'libnpx'
Require stack:
- /usr/share/npm/bin/npx-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> (/usr/share/npm/bin/npx-cli.js:3:13)
at Module._compile (node:internal/modules/cjs/loader:1101:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
at Module.load (node:internal/modules/cjs/loader:981:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12) {
code: 'MODULE_NOT_FOUND',
requireStack: [ '/usr/share/npm/bin/npx-cli.js' ]
}
What i tried after getting the error,
The solution below;
React: create-react-app fails with error "Cannot find module 'lodash'"
How do I approach resolving this problem so that I can get started with my personal project and learning the framework?

Restart your terminal after updating node version.

Restarted vs-code and it started working fine.Hope this helps someone facing the same error

Related

React Native Error: Cannot find module metro/src/shared/output/bundle

command
npx react-native init gonative
I ran this command in root terminal (parrot linux) and encountered with error.
It says cannot find module 'metro/src/shared/output/bundle'
Node version : v17.3.0
npm version: 8.3.0
npx version : 8.3.0
output
Need to install the following packages:
react-native
Ok to proceed? (y) y
node:internal/modules/cjs/loader:936
throw err;
^
Error: Cannot find module 'metro/src/shared/output/bundle'
Require stack:
- /root/.npm/_npx/7930a8670f922cdb/node_modules/#react-native-community/cli-plugin-metro/build/commands/bundle/buildBundle.js
- /root/.npm/_npx/7930a8670f922cdb/node_modules/#react-native-community/cli-plugin-metro/build/commands/bundle/bundle.js
- /root/.npm/_npx/7930a8670f922cdb/node_modules/#react-native-community/cli-plugin-metro/build/commands/bundle/index.js
- /root/.npm/_npx/7930a8670f922cdb/node_modules/#react-native-community/cli-plugin-metro/build/commands/index.js
- /root/.npm/_npx/7930a8670f922cdb/node_modules/#react-native-community/cli-plugin-metro/build/index.js
- /root/.npm/_npx/7930a8670f922cdb/node_modules/#react-native-community/cli/build/commands/index.js
- /root/.npm/_npx/7930a8670f922cdb/node_modules/#react-native-community/cli/build/index.js
- /root/.npm/_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:999:19)
at require (node:internal/modules/cjs/helpers:102:18)
at Object.<anonymous> (/root/.npm/_npx/7930a8670f922cdb/node_modules/#react-native-community/cli-plugin-metro/build/commands/bundle/buildBundle.js:64:22)
at Module._compile (node:internal/modules/cjs/loader:1097:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1149:10)
at Module.load (node:internal/modules/cjs/loader:975:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
at Module.require (node:internal/modules/cjs/loader:999:19) {
code: 'MODULE_NOT_FOUND',
requireStack: [
'/root/.npm/_npx/7930a8670f922cdb/node_modules/#react-native-community/cli-plugin-metro/build/commands/bundle/buildBundle.js',
'/root/.npm/_npx/7930a8670f922cdb/node_modules/#react-native-community/cli-plugin-metro/build/commands/bundle/bundle.js',
'/root/.npm/_npx/7930a8670f922cdb/node_modules/#react-native-community/cli-plugin-metro/build/commands/bundle/index.js',
'/root/.npm/_npx/7930a8670f922cdb/node_modules/#react-native-community/cli-plugin-metro/build/commands/index.js',
'/root/.npm/_npx/7930a8670f922cdb/node_modules/#react-native-community/cli-plugin-metro/build/index.js',
'/root/.npm/_npx/7930a8670f922cdb/node_modules/#react-native-community/cli/build/commands/index.js',
'/root/.npm/_npx/7930a8670f922cdb/node_modules/#react-native-community/cli/build/index.js',
'/root/.npm/_npx/7930a8670f922cdb/node_modules/#react-native-community/cli/build/bin.js'
]
}
Remove global react-native installer
npm uninstall -g react-native-cli #react-native-community/cli
Install metro bundler
npm install --save-dev metro metro-core
Close all terminal/shell, and then run your command again

Why does a fresh gatsby install return a module not found error?

Description
It all started after I updated Gatsby to the latest version in my project that I would receive an error saying the Gatsby-cli module could not be found (error written below) after running gatsby develop After a lot of troubleshooting, I tried creating a new gatsby site with a fresh install of npm install -g gatsby-cli
and npm install -g gatsby, but I was getting the same error. Even after running gatsby -v I get the same error. It doesn't seem to be installing gastby?
Error Message
C:\Users\ctsyg\AppData\Roaming\npm\node_modules\gatsby-cli\node_modules\yoga-layout-prebuilt\yoga-layout\build\Release\nbind.js:53
throw ex;
^
Error: Package exports for 'C:\Users\ctsyg\AppData\Roaming\npm\node_modules\gatsby-cli\node_modules\clipboardy' do not define a '.' subpath
at resolveExports (internal/modules/cjs/loader.js:419:17)
at Function.Module._findPath (internal/modules/cjs/loader.js:492:20)
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:787:27)
at Function.Module._load (internal/modules/cjs/loader.js:693:27)
at Module.require (internal/modules/cjs/loader.js:864:19)
at require (internal/modules/cjs/helpers.js:74:18)
at Object.<anonymous> (C:\Users\ctsyg\AppData\Roaming\npm\node_modules\gatsby-cli\lib\create-cli.js:24:20)
at Module._compile (internal/modules/cjs/loader.js:971:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1011:10)
at Module.load (internal/modules/cjs/loader.js:822:32) {
code: 'MODULE_NOT_FOUND'
}
Fixed: I had to reinstall node.js for some reason.

MODULE NOT FOUND after running axios

While I was compiling the code using npm start an error occurred.
I create the Axios Instance by running npm install --save axios , but after that i run yarn start its not running.strong text
Here is the error log:
yarn run v1.22.4
$ node scripts/start.js
internal/modules/cjs/loader.js:983
throw err;
^
Error: Cannot find module 'resolve'
Require stack:
- /home/falguni/Documents/the_burger_builder/config/webpack.config.js
- /home/falguni/Documents/the_burger_builder/scripts/start.js
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:980:15)
at Function.Module._load (internal/modules/cjs/loader.js:862:27)
at Module.require (internal/modules/cjs/loader.js:1040:19)
at require (internal/modules/cjs/helpers.js:72:18)
at Object.<anonymous> (/home/falguni/Documents/the_burger_builder/config/webpack.config.js:6:17)
at Module._compile (internal/modules/cjs/loader.js:1151:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1171:10)
at Module.load (internal/modules/cjs/loader.js:1000:32)
at Function.Module._load (internal/modules/cjs/loader.js:899:14)
at Module.require (internal/modules/cjs/loader.js:1040:19) {
code: 'MODULE_NOT_FOUND',
requireStack: [
'/home/falguni/Documents/the_burger_builder/config/webpack.config.js',
'/home/falguni/Documents/the_burger_builder/scripts/start.js'
]
}
error Command failed with exit code 1.
This is showing in my terminal and it is not running the server.
Capitalize your folder names and js file names.
try
yarn add axios
instead of
npm install axios
I am not clear but i think this will work

React Native expo CLI Error: Cannot find module 'semver'

Hi React native masters,
I am trying to create react native app using expo cli.
1-I installed expo globally by:
npm install -g expo-cli
2-Then I checked the version:
expo --version
It showed :6.13.1
3-Then I tried to initiate the app by:
expo init myApp
and it gives me this error:
internal/modules/cjs/loader.js:964
throw err;
^
Error: Cannot find module 'semver'
Require stack:
- C:\Users\Faizan\AppData\Roaming\npm\node_modules\expo-cli\bin\expo.js
[90m at Function.Module._resolveFilename (internal/modules/cjs/loader.js:961:17)[39m
[90m at Function.Module._load (internal/modules/cjs/loader.js:854:27)[39m
[90m at Module.require (internal/modules/cjs/loader.js:1023:19)[39m
[90m at require (internal/modules/cjs/helpers.js:72:18)[39m
at Object.<anonymous> (C:\Users\Faizan\AppData\Roaming\npm\node_modules\[4mexpo-cli[24m\bin\expo.js:4:14)
[90m at Module._compile (internal/modules/cjs/loader.js:1128:30)[39m
[90m at Object.Module._extensions..js (internal/modules/cjs/loader.js:1167:10)[39m
[90m at Module.load (internal/modules/cjs/loader.js:983:32)[39m
[90m at Function.Module._load (internal/modules/cjs/loader.js:891:14)[39m
[90m at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12)[39m {
code: [32m'MODULE_NOT_FOUND'[39m,
requireStack: [
[32m'C:\\Users\\Faizan\\AppData\\Roaming\\npm\\node_modules\\expo-cli\\bin\\expo.js'[39m
]
}
Please help me out in this, Thanks!
npm install -g expo-cli --force
try this it's work for me
I am pleased to announce the solution to my challenge.
I actually used it in powershell and got expo-cli installed globally in my machine
npm install --global expo-cli

Yeoman angular generator error

When I'm using the angular yeoman generator, I'm getting the following error:
module.js:340
throw err;
^
Error: Cannot find module './lib/pack.js'
at Function.Module._resolveFilename (module.js:338:15)
at Function.Module._load (module.js:280:25)
at Module.require (module.js:364:17)
at require (module.js:380:17)
at Object.<anonymous> (C:\Users\kra\AppData\Roaming\npm\node_modules\generator-karma\node_modules\yeoman-generator\n
ode_modules\download\node_modules\decompress\node_modules\decompress-tarbz2\node_modules\tar\tar.js:171:16)
at Module._compile (module.js:456:26)
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 Module.require (module.js:364:17)
Any idea why?
npm version 1.4.28
node version 0.10.33
yeoman version 1.3.3
Try remove your generator-karma and generator-angular, run npm cache clean, and install them again
I just had a similar issue, this might not be the solution but your version of npm is out of date, try typing:
sudo npm install npm -g
As referenced On the npm website (note they use sudo in the example but it might not be necessary). after that:
npm --version
Is currently 2.1.12 so it should be higher than that.
You can then try:
npm update
to upgrade everything to the latest version (See this page).
This may solve the problem.

Resources