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.
Related
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
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....
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!
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.
Why is it necessary to run 'npm install' when I already have all the dependence in node_module folder.
After running 'npm install' successfully on my machine, I want to setup same project on another machine, why do I require run 'npm install' again when I already have downloaded all the dependence in node_module folder?
First of all I want to inform you 2 things:
As your project depend on some packages (node_modules), same as some packages are dependent on other packages.
when we install some package with command npm install package -g then -g will install it in global folder which can be accessed by any project. by using -g, package is not added to node_modules.
Now here is answer of your problem. There might be possible that some dependencies of packages are installed as global on one machine and not on other one. This can happen as developers work on many project on same machine and might be they have installed global packages. So in this case you need to execute npm install command.
npm install extract all your dependencies from your package.json, download it and save them in your node_modules folder. You don't need to run npm install again and again if you already have installed all your dependencies locally.
When ever you installs a new dependency you run npm install <package-name> --save and why --save for the first time? because it adds the new installed dependency on your package.json. We never push node_modules to our git repo only the updated package.json is pushed to repo. In that case if a new person pulls your code from the repo he is only going to run npm install and all the dependencies mentioned on your package.json will going to available on his project locally. Thats a small intro about why we use package.json hope it helps.
Check the version of node in both system .
I guess that would be issue. you local system would have either higher version than the server. May be not able to compile for higher version make sure the version are same for node in both , to reduce the comflict.