npm test error for create-react-app - reactjs

I'm getting this error when I run npm run test for a create-react-app application for the sample test provided. I tried looking for the EMFILE error but I'm unable to understand what's going wrong.
Error: Error watching file for changes: EMFILE
at exports._errnoException (util.js:1022:11)
at FSEvent.FSWatcher._handle.onchange (fs.js:1406:11)

I had the same issue and discovered watchman was not installed.
Run brew install watchman.

Issue is happening since watchman is not installed on your system.
On Linux, you need to do following
Install Watchman using following commands
git clone https://github.com/facebook/watchman.git
cd watchman/
git checkout v4.9.0
sudo apt-get install -y autoconf automake build-essential python-dev libssl-dev libtool
./autogen.sh
./configure
make
sudo make install
Execute tests
sudo npm test

Related

Reactjs - Demo Application is not working

I am trying setup react new setup but it is give me below error
./src/index.css (./node_modules/css-loader/dist/cjs.js??ref--6-oneOf-3-1!./node_modules/postcss-loader/src??postcss!./src/index.css)
Error: Cannot find module '#csstools/normalize.css'
can anyone suggest me to move forward
thanks in advance
I'm able to solve the problem. The problem is that package-lock.json is pointing to the older packages.
To fix, uninstall an install the package again
Uninstall package
$ sudo npm remove csstools/normalize.css
After that, we have to install again
$ npm install csstools/normalize.css
(removing sudo from the npm install command)
rm -rf node_modules
npm cache clean --force
npm install
now try again to run your scripts, it should work
https://github.com/react-toolbox/react-toolbox-example/issues/28
I solve the same problem. The problem is that package-lock.json is pointing to the older packages. Not sure which package is but needs to be updated. The gist is that, you create a fresh reactapp, use your "package.json" to recreate "package-lock.json", and move it over back to your project. Do it AFTER you update the npm and clear the cache. Unfortunately, I didn't keep the exact sequence as I was trying to solve, following steps should be pretty close to what I did.
$ sudo npm cache clear --force
$ sudo npm install -g npm
$ cd <MYREACTAPPDIR>
$ npm install react#latest --save
$ cd ..
$ npx create-react-app tempapp
$ cp <MYREACTAPPDIR>/package.json tempapp/package.json
$ cd tempapp
$ npm install
$ cp package-lock.json ../<MYREACTAPPDIR>
$ cd ../<MYREACTAPPDIR>
$ rm -fr node_modules
$ npm install
$ npm run build
This worked for me (unfortunately a really annoying solution since it gets wiped whenever node_modules gets reinstalled), when recreating with npx create-react-app did not work.
Go to react-app/node_modules/#csstools
Change the name of the normalize.css folder into something else (ex. anormalize.css)
Take the files from the folder and paste them into the #csstools folder
Delete the anormalize.css folder
Source
fixed issue by updating npm to latest version.
sudo npm install npm#latest -g
If you're getting this error, chances are that you haven't used npx to create the react app. You must have used -
create-react-app project_name
Delete the project folder and reinstall it using -
npx create-react-app project_name
It should work this time. npx is a tool for node packages, which also installs some third party packages that running create-react-app alone might not install, hence throws the error.

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!

How install Start Angular template correctly?

I'm new in the Angular development, so I found this template and I would like to use it. So I'm doing this:
sudo apt-get install -y nodejs
sudo apt-get install -y npm
sudo npm install -g bower
sudo npm install -g grunt-cli
Clone the repository of the project:
git clone https://github.com/start-angular/sb-admin-angular.git
cd sb-admin-agular
npm install bower
But when I try to execute the command npm start, it gives me the follow error:
vagrant#TheMachine:~/sb-admin-angular$ npm start
> sb-admin#0.0.0 start /home/vagrant/sb-admin-angular
> grunt serve
/usr/bin/env: node: No such file or directory
npm ERR! weird error 127
npm WARN This failure might be due to the use of legacy binary "node"
npm WARN For further explanations, please read
/usr/share/doc/nodejs/README.Debian
npm ERR! not ok code 0
vagrant#TheMachine:~/sb-admin-angular$
Any idea how to solve that ? Or what is causing it ?
You might be missing some dependencies. Looks like you only installed bower. Try installing all dependencies using
npm install
Re-follow the installation instructions on the Github page from 5-7:
npm install - bower install is ran from the postinstall
npm start - a shortcut for grunt serve
npm run dist - a shortcut for grunt serve:dist to minify the files for deployment
Some installation routines requires to find the binary "node".
But on Debian based systems the binary is named "nodejs".
To get around this problem I created a syslink.
But be aware that this may introduce other problems later.

npm start returns error 127 while setting up angular-seed application

I am trying to setup angular-seed application.
I have installed nodejs with sudo apt-get install nodejs
Installed npm with sudo apt-get install npm
Installed bower with sudo apt-get install bower -g
Installed nodejs-legacy with sudo apt-get install nodejs-legacy
Opened my angular-seed application, ran npm install. This ran perfectly without any errors.
To start the server, I'm trying to use npm start, but it is returning the following information and error.
> angular-seed#0.0.0 prestart /home/venki/Downloads/angular-seed
> npm install
> angular-seed#0.0.0 postinstall /home/venki/Downloads/angular-seed
> bower install
> angular-seed#0.0.0 start /home/venki/Downloads/angular-seed
> http-server -a localhost -p 8000 -c-1
sh: 1: http-server: not found
npm ERR! weird error 127
npm WARN This failure might be due to the use of legacy binary "node"
npm WARN For further explanations, please read
/usr/share/doc/nodejs/README.Debian
npm ERR! not ok code 0
I'm using Ubuntu 14.04 LTS. Please let me know if any further information is necessary.
I assumed that http-server will be installed by default by nodejs but it turns out that it doesn't.
I installed http-server using
sudo npm install -g http-server
Just ran npm start after this. That's it, the problem is solved.
I had to run both the following commands;
sudo npm install -g http-server
apt-get install nodejs-legacy
And then my program trying to use NPM operated correctly.
I installed nodejs-legacy using the following:
apt-get install nodejs-legacy
Then just run npm after this.

JSX gives no output

Im on Ubuntu 14.04
I installed node
sudo apt-get install node
I installed npm
sudo apt-get install npm
I installed react-tools
sudo npm install -g react-tools
When I try:
jsx -h
I get no output. Any ideas what might be wrong? Likely pebcak but I would appreciate a hint.
I uninstalled everything and this time I installed the correct nodejs. Thx FakeRainBrigand.
This time I got:
/usr/bin/env: node: No such file or directory
I solved this with:
ln -s /usr/bin/nodejs /usr/bin/node

Resources