Unable to resolve empty-module.js react-native and metro-cli - reactjs

I've switched over from a windows dev environment to a linux environment and I'm having trouble getting react-native app going again. The application builds with gradle and installs onto the phone through adb perfectly, when I send the app build through metro (npx react-native start) I get the following spit back. The package exists... so I don't understand how its not found. I thing I don't understand is why from /home/hovaness/Public/ignitefolderscan/_ returns when its not a realy directory in the first place...
Error
error: Error: Unable to resolve module /home/hovaness/Public/ignitefolderscan/node_modules/#react-native-community/cli-plugin-metro/node_modules/metro-runtime/src/modules/empty-module.js from /home/hovaness/Public/ignitefolderscan/_: /home/hovaness/Public/ignitefolderscan/node_modules/#react-native-community/cli-plugin-metro/node_modules/metro-runtime/src/modules/empty-module.js could not be found within the project or in these directories:
node_modules
Ignite-cli doctor
System
platform linux
arch x64
cpu 20 cores Intel(R) Core(TM) i9-10900X CPU # 3.70GHz
directory ignitefolderscan /home/hovaness/Public/ignitefolderscan
JavaScript (and globally-installed packages)
node 16.14.2 /bin/node
npm 8.7.0 /home/hovaness/Public/ignitefolderscan/node_modules/.bin/npm
#react-native-community/cli 7.0.3
corepack 0.10.0
expo 44.0.6
jetifier 2.0.0
n 8.1.0
npm 8.7.0
npx 10.2.2
pnpm 7.0.0-rc.6
react-native-cli 2.0.1
yarn 1.22.18
yarn 1.22.18 /bin/yarn
pnpm 7.0.0-rc.6 /bin/pnpm
<no pnpm global package info available>
Ignite
ignite-cli 7.10.8 /home/hovaness/.npm/_npx/e31027f3785124a8/node_modules/.bin/ignite
ignite src build /home/hovaness/.npm/_npx/e31027f3785124a8/node_modules/ignite-cli/build
Android
java 11.0.14.1 /bin/java
android home - undefined

Running npm audit fix --force ended up upgrading the packages to versions that were not compatible with each other creating this error. Don't blindly run this.

I had the same issue, to fix that I did:
remove the node_modules folder
remove yarn.lock or package-lock.json
Run command: npm install --force
if it does not work, try also:
npm install --legacy-peer-deps

Related

A template was not provided. This is likely because you're using an outdated version of create-react-app (NPM issue)

I know this is an old issue but it showed up after upgrading my npm,
A template was not provided. This is likely because you're using an
outdated version of create-react-app. Please note that global installs
of create-react-app are no longer supported. You can fix this by
running npm uninstall -g create-react-app or yarn global remove
create-react-app before using create-react-app again.
I tried to fix it with:
npm uninstall -g create-react-app
yarn global uninstall create-react-app
npx create-react-app [name of folder]
It did not work
The next step, clean node cache
same issue
the last step I removed npm and node from my system and install it again
same issue.
There are some clues here but it does not work for me
source: Template not provided using create-react-app
I just want to repair this, not use flags command options.
Any recommendations are welcome anyway.
I removed all node and npm folders from
/usr/local/bin/node
/usr/local/bin/npm
even a ".npm" and ".node" hidden files that were in my user home folder, and I realize my IDE WebStorm had one also, so I removed my IDE as well, I rebooted the machine just in case as windows computer, and install Node and npm again "stable version" and then the IDE, it works at the moment.
source: How do I completely uninstall Node.js, and reinstall from beginning (Mac OS X)

How to install react on an existing react project using VSC but with a fresh OS installed?

When I started the project a while back from scratch all packaged installed successfully worked on the project for a while I used:
npm create-react-app my-app
I re-installed my OS which is Windows 10 now. How can I start the same project again with out over-writing or changing anything from my project?
I tried
npm start
and
npm install --save-dev react-scripts
got the same error back :
npm : The term 'npm' is not recognized as the name of a cmdlet, function, script file, or operable program.
I hope you first install node.js(npm package) & also JDK on your new OS. After that install react-native-cli globally. npm install -g react-native-cli .
After successful installation, you can create your new app. npx react-native init SampleApp.
I found a solution:
First I installed Node manually from the windows installer https://nodejs.org/en/download/
Then I ran:
npm install react
in the VSC terminal.
It took a little longer than usual for it to load up the page, but it did eventually. I'm not quite sure if there are any bugs my way, but at least got it to start. I will edit the answer, if possible, with updates if there is any problem that shows up. If you do this, make sure to....

can't run npm install in laravel project how to fix it

I'm creating a laravel application with react template, when I run npm install
throws an error exception, I also tried changing folder permissions, removed
node_modules then reinstalled it but not working any solutions???
Judging by the error I see in your console:
pngquant failed to build, make sure that libpng-dev is installed
Seems like you don't have a pngquant package installed. Try the following steps:
Install package locally:
sudo apt-get install libpng-dev
Install npm package:
npm install -g pngquant-bin
If you already have node_modules directory in your project, delete it and install node_modules again:
npm install
According to Image Provided, Everything seems to be fine until it hits this missing package causing the exception to be thrown.
The missing package is libpng-dev: A virtual package.
See the Debian policy for a definition of virtual packages.
You can see here for details.
You have to Run this Command
sudo apt-get install libpng-dev
In case you hit an error saying it has been installed before, It means you have installed another build of this package. Hence, you have to reinstall it.
sudo apt-get install --reinstall libpng12-0=1.2.51-0ubuntu3
And then, try running npm install
I hope it works.
I solved similar issue in my localhost environment by moving libraries from devDependencies{} into dependencies{}
Otherwise
You should set global Node environment called NODE_ENV to development
NODE_ENV=development
References
How to set NODE_ENV to production/development in OS X
Environment variables in Node.js. The Right way!

Node-sass not compiling on Azure

I've deployed my React app onto Azure and i'm currently getting this compilation error when loading up the site:
./src/components/LoadingScreen/LoadingScreen.scss (./node_modules/css-loader/dist/cjs.js??ref--6-oneOf-5-1!./node_modules/postcss-loader/src??postcss!./node_modules/sass-loader/lib/loader.js??ref--6-oneOf-5-3!./src/components/LoadingScreen/LoadingScreen.scss)
Error: Missing binding /home/site/wwwroot/node_modules/node-sass/vendor/linux-x64-64/binding.node
Node Sass could not find a binding for your current environment: Linux 64-bit with Node.js 10.x
Found bindings for the following environments:
- Windows 64-bit with Node.js 10.x
This usually happens because your environment has changed since running `npm install`.
Run `npm rebuild node-sass` to download the binding for your current environment.
I've tried to run npm rebuild node-sass in several places but have had no luck so far. Is this happening because it's being built with Windows but deployed onto a Linux machine? How can I fix this?
just delete node-sass folder under node_modules then execute npm install
You could also try running npm rebuild node-sass after the build in production if the commented answer doesn't work. I believe this error occurs in Docker containers if the node-sass was installed in a separate OS environment (ie windows/linux). So you could run npm run start npm rebuild node-sass so it rebuilds in the correct environment.
If you do delete and rebuild, itt might also be useful to run a npm install on your prod environment BEFORE you do it in development.

npm run build hangs no matter what, cannot upgrade webpack

I cloned a react repository and would like to run it. However, npm run build and npm start hang indefinitely.
I am trying to run the application on a CentOS 7 server which I access via ssh.
I am running:
npm install
and then
npm run build or npm start
Here is what I see:
my-project# build /local/scratch/my-project/app
webpack --mode development --progress
The progress does not seem to display.
I tried updating webpack with:
npm install --global webpack#4.29.6
I know that I need version 4.29.6 or higher. When I run this:
npm webpack --version
I still see version 3.10.10. My package.json file references version 4.29.6.
What should I try next?
Please let me know if I need to provide more information.
There are two mistakes I was making above:
1) npm webpack --version does not show the version of webpack. Instead, it shows my version of npm.
2) I should not have installed webpack globally - this caused issues. I should have installed it locally.
The app still doesn't work...but I can build and see error messages which is a big step forward.

Resources