Npm install/run dev fails for not finding Git Bash - javascript

I have a Javascript project set using React.js. Npm install for nodemon package version 2.0.7 fails with following errors:
It seems that the installation is trying to spawn Git Bash but without success.
Should the installation spawn bash.exe from the folder C:\Program Files\Git\bin instead
of C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Git\Git Bash?
Same error message happens when running npm run dev to start the Node server:
Same errors happen when run from Git Bash.
Earlier nodemon version 1.10.0 installation succeeds with no errors.
I have
OS Windows 10
npm version 6.14.8
node version 14.15.0
git version 2.28.0.windows.1
I think my Git is set to environment path variable correctly.
What could be causing this error?

Related

Gatsby - Command failed with exit code 1: npm install

I'm trying to start my first Gatsby project but keep encountering the same error when creating a new project.
After running gatsby new project-1, I get the following error:
npm ERR! Maximum call stack size exceeded
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/tom.allen/.npm/_logs/2020-06-18T15_54_40_537Z-debug.log
ERROR
Command failed with exit code 1: npm install
Error: Command failed with exit code 1: npm install
- error.js:56 makeError
[lib]/[gatsby-cli]/[execa]/lib/error.js:56:11
- index.js:114 handlePromise
[lib]/[gatsby-cli]/[execa]/index.js:114:26
- task_queues.js:97 processTicksAndRejections
internal/process/task_queues.js:97:5
- init-starter.js:139 async install
[lib]/[gatsby-cli]/lib/init-starter.js:139:7
- init-starter.js:206 async clone
[lib]/[gatsby-cli]/lib/init-starter.js:206:3
- init-starter.js:345 async initStarter
[lib]/[gatsby-cli]/lib/init-starter.js:345:19
- create-cli.js:400
[lib]/[gatsby-cli]/lib/create-cli.js:400:7
I have tried deleting the node_modules inside the project folder and running npm i again but I can't work out how to fix this issue. I'm on node v12.17.0 if that makes a difference... Any help will be really appreciated!
Install nvm
We strongly recommend using a Node version manager like nvm to install Node.js and npm. We do not recommend using a Node installer, since the Node installation process installs npm in a directory with local permissions and can cause permissions errors when you run npm packages globally.
npm's docs
If you have installed Node via some package manager or some Node installer, first of all, uninstall it and instead install Node from nvm. In my case I had installed Node via NodeSource, so:
sudo apt purge node
Go ahead and install nvm, following the instructions on the Github repo. I had to include the shell script manually in my ~/.zshrc because the nvm script didn't do.
Install node and npm via nvm
Run the following to install Node and npm: nvm install node
Now, in order to make gatsby new works, you will need to install a previous version of node, which will be: v14.13.1. Run the following command and you will install the mentioned version:
nvm install 14.13.1
Select the Node version to use if is not selected:
nvm exec 14.13.1 node --version
Gatsby
Now, you only need to install Gatsby CLI, and then simply use it.
Run the following: npm install -g gatsby-cli
Go to the folder where you want to create your project and then run:
gatsby new [your-project-name] https://github.com/thomaswangio/gatsby-personal-starter-blog
So there's a few suggestions:
Hard cache removal: npm cache clean --force
Upgrade gatsby-cli version: npm update
Delete node_modules and .cache folder
Keep in mind removing package-lock.jsonto unlock you dependencies.

Error when attempting to deploy Next.js app to Zeit cloud, running in dev mode

I am unable to deploy my Next.js App to Zeit using the now command.
I tried uninstalling sass reinstalling npm i node-sass as well as npm i node-sass --force. None of this worked. I get the following error.
Node Sass could not find a binding for your current environment: OS X 64-bit with Node XX.X.X
The application must deploy or at least run in dev mode 'now dev'. It runs fine in my local dev environment when I run 'npm run dev'.
How I fixed the problem was, I wrote a bash script that does the following steps.
# Delete build files
sudo rm -rd .next
# Delete node modules
sudo rm -rd node_modules
# Then I ran this without installing the node_modules again
now dev
When I let the zeit builder install the node_modules the test deployment worked like a charm.

Unable to run Electron Quick Start in WSL

Hi I'm running Ubuntu 16.04.3 LTS on Windows Subsystem Linux. I'm trying to run the Quick Start first app as listed in this section here https://electronjs.org/docs/tutorial/first-app however, I keep getting the same error no matter if I clone the repository, write it myself, or delete and reinstall the Electron module.
> electron .
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! first-electron#1.0.0 start: `electron .`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the first-electron#1.0.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
For reference I'm running
Node: 9.11.1
NPM: 5.8.0
Electron needs to open a chrome browser window. So, when you run it from WSL using a node.js that was installed in WSL, I guess it would try to start the chromium browser for Ubuntu, which will not work out of the box, because:
Microsoft doesn't support graphical programs on WSL. Bash on WSL is intended for running command-line programs that developers might need, but it's possible to run graphical Linux desktop programs on Windows using the Bash shell. To be more precise, you'll be able to display graphical programs running in WSL on a Windows 10 desktop by using an X server which runs on Windows 10.
https://virtualizationreview.com/articles/2017/02/08/graphical-programs-on-windows-subsystem-on-linux.aspx
I found the easiest way is to install electron on Windows then start it from WSL.
Steps:
Make sure you have Node.js & npm installed on your Windows machine (you can remove them afterwards)
Open cmd.exe, move to your project directory and run npm install electron --save-dev.
This will install the Windows version of the prebuilt Electron binary instead of the Linux one, which would occur if you try to install from WSL. (This is the actual trick)
Enter Bash on Ubuntu on Windows, move to your project directory then run ./node_modules/.bin/electron (or use an npm script) to launch your Electron app
Though, I'm not sure this is very convenient, it seems to work well.
I hope this will help people encoutering the same issue in the future!
Ref: https://github.com/electron-userland/electron-prebuilt/issues/260
run a X-server app in windows, then export DISPLAY , run the npm start.

Error install Angular 4 using npm

When i install angular and try to use this command line :
ng -v i got an error (check jpeg file) ..
I have installed : node 6.10.3
someone have a solution
Those errors are caused by you manually stopped #angular/cli from installing packages into your project folder.(When running ng -v in a angular/cli project folder, angular/cli will trying to output your version information of installed #angular/xxx packages).
mention that when you pressed Ctrl + C, the task will stop even you pressed N later.
Solution:
run npm install at your project folder and wait for it to be finished, then when you run ng -v again, the errors will gone.

Node.js imagemin on CentOS

I am trying to use Node.js imagemin to compress a lot of images on my server. I like using imagemin because I know how to point it at specific directories.
I am using CentOS 6 and when I run my file, I get the error:
node_modules/imagemin/node_modules/imagemin-pngquant/node_modules/pngquant-bin/vendor/pngquant: /lib64/libc.so.6: version `GLIBC_2.14' not found
Also, when I installed imagemin with npm install imagemin, I got an error that said:
Error: pngquant failed to build, make sure that libpng-dev is installed
Any ideas on what I can do to solve this?
(Problem de facto already solved in the comments - but for the sake of completion and future generations I'm posting an actual answer).
Error: pngquant failed to build, make sure that libpng-dev is installed
This error means that the system is lacking libpng development library, which is needed to install imagemin Node.JS module. To install it on CentOS 6, you need to issue this command:
yum install libpng-devel
Please note that both package manager (here - yum) and package name (libpng-devel) can vary between different Linux distributions.
I had the same issue with CentOS 7 even with libpng-devel installed. It seems the package carries a precompiled binary program in node_modules/pngquant-bin/vendor/pngquant which is somehow incompatible with the Linux installation (CentOS 7 latest).
I have made a solution to the problem by replacing this binary file with the one that is available for CentOS 7.
I am installing the official package pngquant with yum, first. Then I am installing the node modules. You can remove the node_modules folder if you like prior to install action. Its not required, though.
The error will be shown as usual (the program file is not yet replaced):
⚠ The `node_modules/pngquant-bin/vendor/pngquant` binary doesn't seem to work correctly
⚠ pngquant pre-build test failed
ℹ compiling from source
✖ Error: pngquant failed to build, make sure that libpng-dev is installed
at ChildProcess.exithandler (child_process.js:206:12)
at emitTwo (events.js:106:13)
at ChildProcess.emit (events.js:191:7)
at maybeClose (internal/child_process.js:877:16)
at Process.ChildProcess._handle.onexit (internal/child_process.js:226:5)
However, after replacing the binary file everything should be fine.
sh
yum install libpng-devel pngquant
npm install
rm -rf node_modules/pngquant-bin/vendor/pngquant
ln -s /usr/bin/pngquant node_modules/pngquant-bin/vendor/pngquant
After that you can run any command you like, "imagemin:dynamic", etc. It should work properly.
Summary
Generally speaking, the problem appear to be inside the pngquant-bin node package. This solution might help for other Linux distributions as well.
The solution itself is to install the officially supported version of pngquant with the OS package manager and to replace the binary inside the pngquant-bin vendor folder after its installation.
Update
In addition, there is a recent problem that is still related with pngquant npm package. It seems that there is a buggy release of it - lock the required pngquant package in your package.json to older version (last properly running version for you).
The previous solutions didn't work for me. I'm using centos 7.4
When executing executing
# npm install
I recieved the error:
✖ Error: pngquant failed to build, make sure that libpng-dev is installed`
While trying to install libpng-devel, it says it's already installed.
Solution
Update the nodejs & npm version if it's using old one.
I have updated to
Nodejs Version
[root#hosting ~]# node -v
v8.10.0
npm version
[root#hosting ~]# npm -v
5.7.1
Check the installed libpng-devel on your server.
[root#hosting ~]# rpm -qa |grep libpng
libpng-1.5.13-7.el7_2.x86_64
libpng-devel-1.5.13-7.el7_2.x86_64
If you are using epel repo then it will install the latest version. For more libpng release check
[root#hosting ~]# yum list |grep libpng
I have installed
yum install libpng12-1.2.50-10.el7.x86_64 libpng12-devel-1.2.50-10.el7.x86_64
moved node modules
mv node_modules node_modules_bak
Then type
# npm install
in my case, I'm using a CentOS instance on Amazon WS and I faced same problem here. I solved it by installing libpng12 and libpng12-devel (yum install libpng12 libpng12-devel), then running yarn install (or npm install) and the packages did installed correctly.
Just this!
Here's how I resolved the issue for my case:
Delete node_modules:
rm -rf node_modules
Install following dependencies:
sudo dnf install libpng-devel pngquant gcc make libpng12 libpng12-devel
Rebuild dependencies. I use yarn:
yarn

Categories

Resources