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

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!

Related

ReactJS: Pngquant failed to build, make sure that libpng-dev is installed

I am trying to setup a react project. It has lot of dependencies and while downloading one of module it is throwing this error. This is on windows.
pngquant failed to build, make sure that libpng-dev is installed
Output:
‼ unable to get local issuer certificate
pngquant pre-build test failed
compiling from source
pngquant pre-build test passed successfully
Error: pngquant failed to build, make sure that libpng-dev is installed
You didn't installed lib-png so that error is coming.Try to install lib-png first.
sudo apt-get install libpng-dev
npm install -g pngquant-bin
To expound more on #Mukesh's answer.
I experienced this issue when building a react project that uses the imagemin-pngquant package.
When I run npm install on the server I get the below error:
pngquant pre-build test failed
compiling from source
pngquant pre-build test passed successfully
Error: pngquant failed to build, make sure that libpng-dev is installed
Here's how I fixed it:
Install libpng-dev package on your machine/server:
sudo apt-get install libpng-dev
Add pngquant-bin package to your npm packages in the package.json file (if it doesn't yet exist):
"dependencies": {
.
.
.
"imagemin-pngquant": "^9.0.1",
.
.
.
}
OR
Run the command to install the pngquant-bin package:
npm install imagemin-pngquant --save // to install the latest
OR
npm install imagemin-pngquant#9.0.1 --save // to install a specific version
Note: You can try npm install imagemin-pngquant#5.0.1 --save if you encounter issues with the latest version.
Now everything should be fine if you install the npm packages and build the project again using:
npm install
npm run build
That's all.
I hope this helps
On Ubuntu you can try to fix it with apt-get install -y libpango1.0-dev command, worked for older node v6
I faced the same issue:
Solution
Step 1
sudo apt-get update -y
Step 2
sudo apt-get install -y libpng-dev
These two steps sorted out my issue and working fine.
This worked for me on Windows:
Run Windows PowerShell as Admin
npm install --global --production windows-build-tools
If you have made any previous npm installation attempt which you most likely had, clean everything and then do a fresh dependency installation:
rm node_modules -R
rm package-lock.json
npm install
Good luck!

ERROR in Cannot find module 'node-sass'

Config: macOS High Sierra, version 10.13.2, node:v8.1.2 npm:5.0.3
When I run npm start in my angularjs project I get this error:
ERROR in Cannot find module 'node-sass'
After this I run:
npm i node-sass
Now I get this error:
gyp: No Xcode or CLT version detected!
gyp ERR! configure error
gyp ERR! stack Error: `gyp` failed with exit code: 1
Why won't npm install node-sass? How can I install node-sass?
Here's the solution:
sudo npm install --save-dev --unsafe-perm node-sass
Enjoy!
Edited to explain the options (from comments):
--save-dev is used so that your app is able to find the module in local node_modules. --save-dev adds package to devDependencies in package.json. --unsafe--perm is used to run install scripts as root. To avoid sudo, use nvm instead. --unsafe--perm is really not needed as sudo is already mentioned. So the command basically air tights the script to install node-sass at any cost.
This error is for node-sass is not present ... to solve this just you want to run following command
npm install node-sass
According to node-sass github page, supported node.js version vary release by release.
https://github.com/sass/node-sass
Example:
Check the version of node you are running.
node -v
-> v12.0.0
you need node-sass v4.12+. so you can
npm install node-sass#4.12.0
or if 4.12.0 is the latest
npm install node-sass#latest
(npm install node-sass will install the latest version in many cases, but remember that it does not always install the latest(in this example 4.12.0) if dependency in package.json is written like ^3.0.0, ~4.11.0)
What's the difference between tilde(~) and caret(^) in package.json?
Lastly, using sudo with npm is not a good practice. Please refer to this article.
https://medium.com/#ExplosionPills/dont-use-sudo-with-npm-still-66e609f5f92
Doing npm uninstall node-sass and then npm i node-sass did not work for me.
Solution worked for me is npm install --save-dev node-sass.
Happy Coding..
Run:
npm rebuild node-sass --force
and it'll work fine.
It worked for me...
sudo npm rebuild node-sass --force
node-sass is not being installed and it can be one of many reasons
You have not installed it
npm install node-sass --save-dev
You are having a permissions error
sudo npm install --save-dev --unsafe-perm node-sass
You had a memory issue because it tried to make it (build from c code in your platform),this applies to some platforms and node versions
node --max_old_space_size=8000 $(which npm) install node-sass --save-dev
Your node and npm versions are not compatible,which most probably generated a failure in the build process,
In this case use n or nvm to make sure you have the same version in the new and original environment, the one where it did work, as this is usually by using different versions in different environments
This is what worked for me. I first uninstall node-sass. Then install it back.
npm uninstall node-sass
npm install --save-dev node-sass
It failed for me because I was using the latest version of node (12.7.0) I then had to explicitly install the latest version of node-sass with:
npm install node-sass#4.12.0
I have fix this problem without installing node-sass by this command:
npm install node-sass#4.12.0 --no-save --unsafe-perm
One of the cases is the post-install process fails. Right after node-sass is installed, the post-install script will be executed. It requires Python and a C++ builder for that process.
The log 'gyp: No Xcode or CLT version detected!' maybe because it couldn't find any C++ builder. So try installing Python and any C++ builder then put their directories in environment variables so that npm can find them. (I come from Windows)
I checked the Node version in my local machine, which is v10.11.0.
Then when I checked my development machine, where the error occurred, it had Node version V.10.8.0.
Upgrading Node to v10.11.0 in my development machine fixed the issue.
Hope this helps.
In my case I had to also had to perform:
npm install sass-loader
To fix the problem
There is an issue with downloading npm dependencies due to network which you have. try to download the npm dependencies in open network . you won't get any issue. i am also faced this similar issue and resolved finally.
use below commands: npm install (it will download all depedencies)
npm start to start the angular application
npm install node-sass will do the job in most of the cases, as it will add missing sass npm dependency module doesn't exist or it will overwrite previous crashed version.
For Mac Users use sudo in front of above commands.
On Windows machines npm rebuild node-sass --force may not work for some users because it's essentially saying, "please force npm to rebuild the sass node module for me". It will not work because that module doesn't exist.
Whenever you did npm install to the initial installation, the sass module did not get installed, which is why this problem occurs.
My problem was that a webfilter didn't allow me to download the node-sass package, when I executed the command
npm i
After the installation of the Windows Build Tools
npm i -g windows-build-tools
it build node-sass on it's own and now I can use it.
PS: I also installed Python 2.7.17 before, but I don't think that helped.
Try sudo npm install node-sass#4.12.0 if your node version is 12.
you must install node-sass in dev section of package.json
npm install --unsafe-perm node-sass --save-dev
If you run
npm install node-sass
and it still doesn't work remember to change permission to folder
I have also been facing this error. None of the above methods work for me. Please follow this as it worked for me.
For Installing node-sass in Ubuntu 16 via npm :-
You can install with npm 5.2.0 Version
If you are using nvm :-
nvm install 8.2.1
nvm use 8.2.1
npm install node-sass
If you are using npm separately then upgrade or downgrade npm version to 5.2.0
npm install node-sass
I ran into this error while I was using Microsoft Visual Studio Code's integrated git terminal. For some weird reason VS code was not allowing me to install 'node-sass'. Then I used 'Git Bash' (which was installed with git) and ran the following command:
npm install node-sass
It worked for me. I don't know why & how it worked. If anyone has any explanation please let me know.
You should try to check the log generated by npm install.
I have faced the same issues, and I found the error that python2 is not found in the path (environment variable).
After installing Python, everything worked fine.
I had a similar issue when I tried to run a project.
First i uninstalled the current version
npm uninstall node-sass
Then i reinstalled to the latest version with
npm install node-sass
Upgrading to latest version of nodeJS solved my problem
npm install --save-dev --unsafe-perm node-sass
This will do magic, you can use it with sudo
I had the same error when installing dependencies in Angular. I've tried aforementioned techniques but none of them worked until I've deleted package-lock.json which was previously created when running Node v11.
Now I'm using Node v12 so this is how I got resolved.
I repeat if you have package-lock.json delete it, file and then install dependencies.
Exactly same issue i was also facing and i tried all above answers but could not resolve, Below is the command which fixed my problem.
npm install sass-loader sass webpack --save-dev
https://www.npmjs.com/package/sass-loader
I've fixed this problem by installing v10.16.10 node version.
I met same issue installing node-sass when I am on Node 12.9.0
Once switching to Node 10.19.0, the issue is gone.
Reference: https://github.com/sass/node-sass/issues/2632
There seems to be an issue with the version "node-sass": "4.5.3", try updating to the latest version. Such as you could try adding ^ "node-sass": "^4.5.3" for the latest version

Command not found returned in terminal on almost every line

I'm trying to work with AngularJS but I can't even get pass installing it via Terminal.
I enter this onto the command line
npm install -g #angular/cli
I get this as a result
- bash: npm: command not found
I seem to be getting this same error log on almost every command, the rest return nothing
I'm stumped as to why it's not working.
For reference I'm using OS X 10.9.5
Make sure you got node installed which comes with npm
https://nodejs.org/en/
You error looks like you don't even have node installed on your computer, first of all, you need to install node js on you computer, once you’ve installed Node.js, you can make sure you’ve got the very most recent version of npm using npm itself: sudo npm install npm -g.
Then you can continue your installation with the step below:
To install #angular/cli locally run npm install #angular/cli --save, while to install it globally run npm install -g #angular/cli.
But if it requires a root access, then you have to include the sudo which will then be sudo npm install -g #angular/cli.
I figured it out. I needed to adjust the .bash_profile by entering this
echo "export PATH=/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/b‌​in" >> ~/.bash_profile
Thanks to everyone who gave advice :)

Error: Cannot find module '#ionic/app-scripts'

I'm new to Ionic. I was following the Ionic documentation "get started", created a project sample named "super". The problem is that when I run the command line ionic serve in the project directory, it threw an error Error: Cannot find module '#ionic/app-scripts'
Try installing app-script from npm
npm i #ionic/app-scripts
To get the latest #ionic/app-scripts, run the following command:
npm install #ionic/app-scripts#latest --save-dev
app-scripts currently compatible with node 6 and 7.
İf you installed node 8, then please uninstall and install node 6 stable version.
This solved error and now i can use ionic 3, angular 4 .
Take care!
do not downgrade the node version, update the version of "app-scripts":
To get the latest #ionic/app-scripts, please run:
npm install #ionic/app-scripts#latest --save-dev
I was facing same issue, here is what I did-
Removed node_modules from directory (Manually).
open project dir
run this command-
npm install
That fixed those errors for me.
See here.
I had this issue , i solved it by deleting node_modules/ folder and ran the command npm installnow my app works
I tried every non-downgrade solution mentioned in this thread, in all kinds of ways and none of them worked. With nothing left to lose, I went down the downgrade route (I used sudo apt-get purge --auto-remove nodejs to remove previous 8.x version and then installed the last stable ver on the 6.x branch using the nodesource ppa).
Still got the same errors trying to run in the original project folders, but then I created a new project and ionic serve worked just fine in that space.
FWIW, I did not need to run npm update or npm i #ionic/app-scripts afterwards, but I did find it necessary to adopt the habit of running commands with sudo in front (or you sudo -s into root account).
I ran into the same issue and i had problems fixing it. However i update my app scripts npm install -g #ionic/app-scripts#latest --save-dev to the latest version and my problem was solved
npm install -g #ionic/app-scripts#latest --save-dev
Error: app-script not found/ app-script not installed/ app-script module is not found
Try this work for me, Your also:
- npm cache clean --force
- npm install #ionic/app-scripts#latest --save-dev
- npm install -g #angular/cli
I had the issue, solved by execute cnpm i #ionic/app-scripts.
Just open a new terminal window/session. I could not figure it out, but it's probably related to env.
None of the options worked for me.
But I could make it work by updating node with
npm update
After this, the problem was solved and the application started.
Good Luck.
I had the same problem and here is what worked for me
I was trying to run the program using VSCode terminal, Instead I used the windows cmd and it ran perfectly. I think the error is in VSCode terminal, it cannot identify the app-scripts module inside the project. Maybe it will be fixed in a later update.
Delete node_modules and package-lock.json
rm -rf node_modules package-lock.json
npm install
Reference:
https://github.com/ionic-team/ionic-cli/issues/3399
After half a day trying to solve this
And after:
python version error
node-sass misconfiguration error
I did the following
Remove node-modules folder
Run "npm audit fix --force"
Downgrade webpack installation "npm uninstall webpack && install webpack#3.12.0"
The last one because ionic build was giving me an error on that package after the audit
In my case, I need to set NODE_ENV to production then it installs successfully
set NODE_ENV=production
npm install #ionic/app-scripts#latest --save-dev
You must create the project as administrator if you have mac or linux uses sudo, if you have windows run the console as administrator and create the project
My issue was solved after run this script:
npm i #ionic/app-scripts

Local Npm module "grunt-legacy-util" not found. Is it installed?

i have a problem with grunt serve,(i dont know if it's normal) grunt serve said me "works without errors" but the first message is local npm module "grunt-legacy-util" not found. Is it installed?", i need to delete node_modules folder and make npm install to can work with the server. i do grunt update, npm install grunt-legacy-util, npm install,npm update, but say same message...i use angularjs make with yeoman and webstorm, any idea please?
You can run a sudo command on it as perhaps the file isn't accessible/hidden (for some odd reason).
sudo npm install -g grunt-legacy-util
Check out this GitHub post should that not work: https://github.com/Widen/fine-uploader/issues/1165
It could also be that your NPM that is installed globally is clashing with the NPM in your root directory. Though unlikely.
This is what worked for me:
npm update
The running this following commands again fixed it for me:
npm install -g bower,
npm install -g grunt-cli,
bower install,
npm install.

Resources