Fix "Cannot find module 'libnpx' " on react-native init - react-native

With a fresh project, after running react-native init {project},
during the phase "Installing required Cocoapods dependencies", this error is thrown:
Error: Cannot find module 'libnpx'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:649:15)
at Function.Module._load (internal/modules/cjs/loader.js:575:25)
at Module.require (internal/modules/cjs/loader.js:705:19)
at require (internal/modules/cjs/helpers.js:14:16)
at Object.<anonymous> (/usr/local/lib/node_modules/npm/bin/npx-cli.js:3:13)
at Module._compile (internal/modules/cjs/loader.js:799:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:810:10)
at Module.load (internal/modules/cjs/loader.js:666:32)
at tryModuleLoad (internal/modules/cjs/loader.js:606:12)
at Function.Module._load (internal/modules/cjs/loader.js:598:3)
(node:27038) UnhandledPromiseRejectionWarning: Error: Failed to install CocoaPods dependencies for iOS project, which is required by this template.
Please try again manually: "cd ./RNimage/ios && pod install".
Following the suggestion to run pod install, the same error is thrown in addition to
[!] Invalid 'Podfile' file 767: unexpected token at ''.
# from /Users/.../Desktop/Development/RNproject/ios/Podfile:42
# -------------------------------------------
#
> use_native_modules!
# end
# -------------------------------------------
I haven't even touched the project why is this happening and how do i fix it?
Before this i ran sudo chown -R 501:20 "/Users/vorousjames/.npm". I dont know if thats significant to this issue but it has broken alot.

In my case, I just updated nodejs using sudo n stable. After a successful upgrade, it showed the warning that the executable path for node has changed and I need to restart the current shell. I forgot to restart the shell, and got this error message. It worked fine after restarting.

No need to delete any files as for the above issue.
So, to fix the problem just install the node from:
https://nodejs.org/en/

I had to reset the shell location hash with "hash -r"

deleted node & npm files from usr/local/bin then re-installed node LTS version. npm commands work now

Try install libnpx using the following command :
npm i libnpx
It worked for me : )

Related

Error: No native build was found for platform=win32 arch=x64 runtime=node abi=108 uv=1 libc=glibc node=18.7.0

I am trying to run contentful-starter applation using "npm run dev" command. I am getting the below error. I am littlebit new to npm . Kindly help me, it would be great if you can suggest any solution. Thank you
These are the commands I executed before running "npm run dev"
npm install -g gatsby-cli
gatsby new contentful-starter https://github.com/contentful/starter-gatsby-blog
cd contentful-starter
npm run setup
npm run dev
Error: No native build was found for platform=win32 arch=x64 runtime=node abi=108 uv=1 libc=glibc node=18.7.0
loaded from: D:\contentful\contentful-starter\node_modules\gatsby\node_modules\lmdb
at Function.load.path (D:\contentful\contentful-starter\node_modules\node-gyp-build\index.js:60:9)
at load (D:\contentful\contentful-starter\node_modules\node-gyp-build\index.js:22:30)
at Object.<anonymous> (D:\contentful\contentful-starter\node_modules\gatsby\node_modules\lmdb\node-index.js:17:45)
at Module._compile (node:internal/modules/cjs/loader:1120:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1174:10)
at Module.load (node:internal/modules/cjs/loader:998:32)
at Function.Module._load (node:internal/modules/cjs/loader:839:12)
at Module.require (node:internal/modules/cjs/loader:1022:19)
at require (node:internal/modules/cjs/helpers:102:18)
at Object.<anonymous> (D:\contentful\contentful-starter\node_modules\gatsby\src\util
The problem is that binary for your environment is missing in lmdb-store. Try it with Node version 17. It worked for me.
you should check to make sure your binaries have been properly installed by NPM first, your binary should be at D:\contentful\contentful-starter\node_modules\gatsby\node_modules\lmdb\lmdb-win32-x64, if not, you can install by npm install #lmdb/lmdb-win32-x64
I had the same issue while trying to bring up my environment and suddenly received a network error while the first npm i was going on.
Quick solution, go to the node_modules folder, and wipe it all. Then run npm i again, most likely it will solve your issue.

React install problems with npm

When I run npx create-react-app, I had these errors. Maybe someone knows whats it's wrong? P.S. also had tried npm-install -g create-react-app.
C:\Users\Deividas\Desktop\PAMEGINIMAS>create-react-app my-app
internal/modules/cjs/loader.js:621
throw e;
^
Error: No valid exports main found for 'C:\Users\Deividas\AppData\Roaming\npm\node_modules\create-react-app\node_modules\is-promise'
at resolveExportsTarget (internal/modules/cjs/loader.js:618:9)
at applyExports (internal/modules/cjs/loader.js:499:14)
at resolveExports (internal/modules/cjs/loader.js:548:12)
at Function.Module._findPath (internal/modules/cjs/loader.js:650:22)
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:948:27)
at Function.Module._load (internal/modules/cjs/loader.js:854:27)
at Module.require (internal/modules/cjs/loader.js:1023:19)
at require (internal/modules/cjs/helpers.js:72:18)
at Object.<anonymous> (C:\Users\Deividas\AppData\Roaming\npm\node_modules\create-react-app\node_modules\run-async\index.js:3:17)
at Module._compile (internal/modules/cjs/loader.js:1128:30) {
code: 'MODULE_NOT_FOUND'
}
This seems to be a recent problem with npm. There is an issue open as of the last few hours and it seems like people are working on it. I don't think it's anything to do with yourproject.
The issue
While the issue is being fixed: try installing node version 12.12.0 as shown below (if using nvm) and run create-react-app again.
nvm install 12.12.0
nvm use 12.12.0
I'd try to clear your cache npm cache clean --force. What version of node and npm are you using?

internal/modules/cjs/loader.js:584 issue

I got a problem when I input any npm cmd, it says
internal/modules/cjs/loader.js:584
Operating System: Windows 10 64bit
What shall I do to solve this issue?
internal/modules/cjs/loader.js:584
throw err;
^
Error: Cannot find module 'E:\FED\node_modules\npm\bin\npm-cli.js'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:582:15)
at Function.Module._load (internal/modules/cjs/loader.js:508:25)
at Function.Module.runMain (internal/modules/cjs/loader.js:754:12)
at startup (internal/bootstrap/node.js:283:19)
at bootstrapNodeJSCore (internal/bootstrap/node.js:622:3)
For many people on Mac (not sure about Windows/Linux), the solution is:
Delete node_modules and package-lock.json, then run $ npm install again.
You can also try updating your version of node.
Check version with $ node -v,
install with $ sudo n stable
I was having a similar error but it was because I hadn't had my node_modules(the ones you deleted ) file open in the file I was working on, even though I had run npm Install.
my Error was
Cannot find module _resolveFilename
If you build and deploy another place at a later time for example in an docker image, it may help to bundle the dependencies that the loader cannot find in package.json. Then the packaged are bundled and the loader can find them.
"bundledDependencies": [ "express", "express-http-proxy", ],
"dependencies": { ...}
Before starting any project you have to write this command npm init --yes

The command 'react-native run-android' shows up errors although there is an emulator running (or device connected)

I started a react-native project with 'react-native init' and was created without errors, however, when I used the command 'react-native run-android' in the project directory this is what I got:
throw er
^
Error: EIO: i/o error, read
at Object.fs.readSync (fs.js:675:18)
at Object.readSync (D:\myProjects\react-native\ReactTodoApp\node_modules\graceful-fs\polyfills.js:138:28)
at tryReadSync (fs.js:540:20)
at Object.fs.readFileSync (fs.js:575:19)
at Object.Module._extensions..js (module.js:645:20)
at Module.load (module.js:554:32)
at tryModuleLoad (module.js:497:12)
at Function.Module._load (module.js:489:3)
at Module.require (module.js:579:17)
at require (internal/module.js:11:18).
The same error appears although that android emulator is running or an android device connected, all the same.
I need to know what is the solution to this.
I am using react-native 0.50.3, react-native-cli 2.0.1.
Seems like a Node related error.
Try restarting Node server. Node cannot read polyfills.js. This can happen if multiple command instances are running in same directory at same time.
Sometimes cleaning cache works
Updating or reinstalling react native is a suggested fix.
You could uninstall react-native and then use the following command:
npm install react#reactversion --save.
Note (reactversion) is your desired version you want to have.
You could also just try reinstalling it as:
npm install react --save
Or upgrade with:
npm update react-native

karma start Cannot find module 'jasmine-core'

I was getting the following error when I ran "karma start"
module.js:340
throw err;
^
Error: Cannot find module 'jasmine-core'
at Function.Module._resolveFilename (module.js:338:15)
at Function.require.resolve (module.js:384:19)
at initJasmine (/usr/lib/node_modules/karma-jasmine/lib/index.js:8:42)
at Array.invoke [as 0] (/usr/lib/node_modules/karma/node_modules/di/lib/injector.js:75:15)
at get (/usr/lib/node_modules/karma/node_modules/di/lib/injector.js:48:43)
at /usr/lib/node_modules/karma/lib/server.js:137:20
at Array.forEach (native)
at Server._start (/usr/lib/node_modules/karma/lib/server.js:136:21)
at invoke (/usr/lib/node_modules/karma/node_modules/di/lib/injector.js:75:15)
at Server.start (/usr/lib/node_modules/karma/lib/server.js:101:18)
at Object.exports.run (/usr/lib/node_modules/karma/lib/cli.js:231:26)
at Object. (/usr/lib/node_modules/karma/bin/karma:3:23)
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)
Does anyone know why this is happening? I was running karma in a VM. I tried several npm install commands and nothing worked. After I shutdown my machine for the night and came back the next day the problem went away and everything is working again. So, I'm not blocked anymore.. Anyone have some thoughts on what could be happening?
I solved using npm install jasmine-core --save-dev
try install jasmine-core globally (Jasmine on NPM).
use npm install -g jasmine-core
Even with karma and karma-jasmine installed in the local project's node_modules you must still npm install jasmine.
So for a fresh Karma project:
npm install karma karma-jasmine jasmine to install the required modules locally.
Optionally add --save-dev to write to your package.json.
Note these do not need to be -g globally installed here.
karma start
This step requires you to have Karma installed globally (sudo npm install -g karma).
Navigate to folder:
cd node_modules\karma-jasmine
Run:
npm install
This should download the required dependencies and fix the issue.
Also, it is important to know the installation path where do you have karma.conf.js file.
I have this problem, and have tried every suggestion on the page without it fixing the problem. Well, I haven't yet rebooted, so I'll try that next, but I have closed my shell (git-bash) and re-opened it in case it was an environment variable problem. Something is wrong here and I don't think the problem has been identified yet.