npm run start with error "EMFILE: too many open files" - javascript

I done npm update and broke start project. Using npm run start returns an error:
10% building 0/1 entries 0/0 dependencies 0/0 modulesnode:internal/errors:484
ErrorCaptureStackTrace(err);
^
Error: EMFILE: too many open files, watch
at FSWatcher._handle.onchange (node:internal/fs/watchers:204:21)
Emitted 'error' event on FSWatcher instance at:
at FSWatcher._handleError (/Users/199/WebstormProjects/isu_frontend_common/node_modules/chokidar/index.js:647:10)
at NodeFsHandler._boundHandleError (/Users/199/WebstormProjects/isu_frontend_common/node_modules/chokidar/lib/nodefs-handler.js:303:43)
at /Users/199/WebstormProjects/isu_frontend_common/node_modules/chokidar/lib/nodefs-handler.js:137:5
at foreach (/Users/199/WebstormProjects/isu_frontend_common/node_modules/chokidar/lib/nodefs-handler.js:41:5)
at fsWatchBroadcast (/Users/199/WebstormProjects/isu_frontend_common/node_modules/chokidar/lib/nodefs-handler.js:136:3)
at FSWatcher.<anonymous> (/Users/199/WebstormProjects/isu_frontend_common/node_modules/chokidar/lib/nodefs-handler.js:185:9)
at FSWatcher.emit (node:events:513:28)
at FSWatcher._handle.onchange (node:internal/fs/watchers:210:12) {
errno: -24,
syscall: 'watch',
code: 'EMFILE',
filename: null
}
Node.js v18.12.1
node:internal/process/promises:288
triggerUncaughtException(err, true /* fromPromise */);
^
RpcIpcMessagePortClosedError: Cannot send the message - the message port has been closed for the process 17332.
I've already tried:
Removing node_modules and package-lock.json, clean cache and npm install
Switch Node.js and NPM versions to lastest stable
Installing the project again in another folder
But it didn't help me. What else can I do?

Judging of your filepath's it seems like you are using MacOS. I have experienced this issue a few times on my macbook m1 silicone and was able to resolve this issue by installing Watchman. You can simply do that with the help of brew.
First update brew;
brew update
then execute this command;
brew install watchman
Let me know if this solved your issue.

npm install graceful-fs
It resolve my problem.

Related

Failed to transform react-native-reanimated-65-jsc.aar [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 1 year ago.
Improve this question
BUILD FAILED in 19s
error Failed to install the app. Make sure you have the Android development environment set up: https://reactnative.dev/docs/environment-setup.
Error: Command failed: gradlew.bat app:installDebug -PreactNativeDevServerPort=8081
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:checkDebugAarMetadata'.
> Could not resolve all files for configuration ':app:debugRuntimeClasspath'.
> Failed to transform react-native-reanimated-65-jsc.aar (project :react-native-reanimated) to match attributes {artifactType=android-aar-metadata}.
> Execution failed for JetifyTransform: C:\Users\Rahul\Desktop\lcorn\rb\node_modules\react-native-reanimated\android\react-native-reanimated-65-jsc.aar. > Transform's input file does not exist: C:\Users\Rahul\Desktop\lcorn\rb\node_modules\react-native-reanimated\android\react-native-reanimated-65-jsc.aar. (See https://issuetracker.google.com/issues/158753935)
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 19s
at makeError (C:\Users\Rahul\Desktop\lcorn\rb\node_modules\#react-native-community\cli-platform-android\node_modules\execa\index.js:174:9)
at C:\Users\Rahul\Desktop\lcorn\rb\node_modules\#react-native-community\cli-platform-android\node_modules\execa\index.js:278:16
at processTicksAndRejections (node:internal/process/task_queues:94:5)
at async runOnAllDevices (C:\Users\Rahul\Desktop\lcorn\rb\node_modules\#react-native-community\cli-platform-android\build\commands\runAndroid\runOnAllDevices.js:106:5)
at async Command.handleAction (C:\Users\Rahul\Desktop\lcorn\rb\node_modules\#react-native-community\cli\build\index.js:186:9)
info Run CLI with --verbose flag for more details.
PS C:\Users\Rahul\Desktop\lcorn\rb>
"react": "17.0.2",
"react-native": "0.65.0",
I don't think react-native-reanimated supports Hermes on Android with React Native 0.65.0. I was able to fix it removing react-native-reanimated because I don't use it. Maybe you can remove it or disable Hermes.
Installing react-native-reanimated#2.3.0-alpha.2 also fixes it.
This issue has been fixed in the latest build (alpha release).
yarn add react-native-reanimated#2.3.0-alpha.3
Here is the list of version releases: https://www.npmjs.com/package/react-native-reanimated?activeTab=versions
New upgrade is not yet released react-native-reanimated-65-jsc.aar.
After the installation of the package, navigate to node_modules folder and search for react-native-reanimated. Navigate to android and see if anything ending with 65 is visible.. else it wont work.
Alternate options, [with downgrade to 0.64.2] it does work... but the version gets reset after the build.
This is one of the key file to be updated node_modules> react-native-reanimated > android > build.gradle to make it work
Follow the instructions as given in the site
https://docs.swmansion.com/react-native-reanimated/docs/installation/
set the following too enableHermes: true .. No harm in setting it
Now follow these steps
in your android > gradle > wrapper>gradle-wrapper.properties change
distributionUrl=https://services.gradle.org/distributions/gradle-6.8-all.zip
android > build. gradle. Change these two items; as class path goes set with 6.8-all goes with 4.2.2
uninstall react-native .65 and run for 0.64.2
delete your package-lock.json
watchman watch-del-all
Delete node_modules
run yarn install
yarn start --reset-cache
rm -rf /tmp/metro-*
[This can be an optional step..as RN .64 is set]
Now go back to the node_modules folder and search for the 'react-native-reanimated' folder and change this
artifacts.add("default", file("react-native-reanimated-${minor}.aar"))
to
artifacts.add("default", file("react-native-reanimated-64.aar"))
Now start with your build.. you should not see the issue reported.
. Update
Just install react-native-reanimated#2.3.0-alpha.3 or any updated version.
It will fix this issue.
I have upgraded my react native vers to 0.65.1 and had this problem too. Try to make:
npm uninstall react-native-reanimated
npm i react-native-reanimated
cd android
./gradlew wrapper
cd ..
npx react-native run-android
If you don't want to use alpha version of the library, you may install react-native-reanimated#2.2.1 too for React Native 0.65

expo-cli is installed correctly but run with some errors

I installed expo-cli globally on my machine to start working with react-native, the files of expo are located in the C:\\users\username\node_modules. Despite of installing it globally, windows command line (cmd) doesn't recognize the command expo.
To make the expo command global, i added the path C:\Users\username\node_modules\.bin to environment variables, so the problem of using expo command is solved, i can use it to create a simple react-native application.
When i try to run the application using:
expo start --web
i get the following error:
D:\Testing\myapp>expo start --web
Starting project at D:\Testing\myapp
Expo DevTools is running at http://localhost:19002
Opening DevTools in the browser... (press shift-d to disable)
Error: spawn cmd ENOENT
at Process.ChildProcess._handle.onexit (internal/child_process.js:267:19)
at onErrorNT (internal/child_process.js:469:16)
at processTicksAndRejections (internal/process/task_queues.js:84:21)
Please help me to fix it.
This is a strange error. ENOENT means file not found and spawn cmd means it's trying to run something. One possible fix I found is, editting your state.json file in the location HOMEPATH\.expo\state.json.
Add "openDevToolsAtStartup": false above the PATH line.
Hope this works for you.
Note: If you're using Windows 10, your state.json file will be in C:\Users\your-username\.expo\state.json

ERR! code ELIFECYCLE - Error while executing TodoMVC

I am trying to use TodoMVC for comparing performance of some JS frameworks.
I have done a clone of online repository,$ npm install inside main directory, the command $ gulp test-server is executed correctly (application started on http://localhost:8000/) but when i run $ npm run test it shows the following errors which i don't know how to solve
enter image description here -> this is solved
enter image description here -> For the second error i have tried to do
1)npm cache clean --force
2)delete node_modules folder
3)delete package-lock.json
4)npm install
but is still shows the same error and can not run $ npm run test
Cypress installation error -> enter image description here
The port 8000 is already in use, this is written black on white in the image you linked, first line of the error message, so you already have a server using that port. that's what EADDRINUSE means. Kill the process listening at 8000 or launch your tests on another address if possible.
For your second error try to install Cypress globally:
sudo npm install -g cypress
And than try to run the test

App stops working after updating npm and node on MacOS

So I've made the big mistake of updating npm and node from versions 3.10.10 and 6.10.2, respectively to 5.6.0 and 9.3.0
Now my app doesn't work so I am getting quite desperate here. When I attempt to run it, I get the following error:
/Users/me/Workspace/MyApp/node_modules/node-sass/lib/binding.js:13
throw new Error(errors.unsupportedEnvironment());
^
Error: Node Sass does not yet support your current environment: OS X 64-bit with Unsupported runtime (59)
For more information on which environments are supported please see:
https://github.com/sass/node-sass/releases/tag/v4.5.3
I've looked up the error and haven't found much, except deleting the node_modules folder and doing npm install. Neither of which work. This now gives me the following error:
node-pre-gyp ERR! Tried to download(403): https://mapbox-node-binary.s3.amazonaws.com/sqlite3/v3.1.8/node-v59-darwin-x64.tar.gz
node-pre-gyp ERR! Pre-built binaries not found for sqlite3#3.1.8 and node#9.3.0 (node-v59 ABI) (falling back to source compile with node-gyp)
ACTION deps_sqlite3_gyp_action_before_build_target_unpack_sqlite_dep Release/obj/gen/sqlite-autoconf-3150000/sqlite3.c
TOUCH Release/obj.target/deps/action_before_build.stamp
CC(target) Release/obj.target/sqlite3/gen/sqlite-autoconf-3150000/sqlite3.o
I am not sure where to go from here but am not getting desperate. What is going on? Is there anything I can do or should I just reverse to a previous version of node and npm?
You'll need to run npm rebuild, because Node-sass uses C++ addons, and that command
runs the npm build command on the matched folders. This is useful when you install a new version of node, and must recompile all your C++ addons with the new binary.
There's probably also no reason not to update node-sass to the current release 4.7.2.
Have a look at another handy package called ncu that can help you bulk-upgrade your package.json. Don't do it carelessly, you may create instability, but it's a handy start if you have a small number of specified dependencies.

npm - EPERM: operation not permitted on Windows

I ran
npm config set prefix /usr/local
After running that command,
When trying to run any npm commands on Windows OS I keep getting the below.
Error: EPERM: operation not permitted, mkdir 'C:\Program Files (x86)\Git\local'
at Error (native)
Have deleted all files from
C:\Users\<your username>\.config\configstore\
It did not work.
Any suggestion ?
Running this command was my mistake.
npm config set prefix /usr/local
Path /usr/local is not for windows. This command changed the prefix variable at 'C:\Program Files (x86)\Git\local'
To access and make a change to this directory I need to run my cmd as administrator.
So I did:
Run cmd as administrator
Run npm config edit (You will get notepad editor)
Change prefix variable to C:\Users\<User Name>\AppData\Roaming\npm
Then npm start works in a normal console.
This is occurring because windows is not giving permission to the user to create a folder inside system drive. To solve this:
Right Click
The Folder > Properties > Security Tab
Click on Edit to change Permissions > Select the user and give Full Control to that user.
Sometimes, all that's required is to stop the dev server before installing/updating packages.
I solved the problem by changing windows user access for the project folder:
Here is a screenshot:
http://prntscr.com/djdn0g
Restarting VsCode solved it for me!
I recently had the same problem when I upgraded to the new version, the only solution was to do the downgraded
To uninstall:
npm uninstall npm -g
Install the previous version:
npm install npm#5.3 -g
Try update the version in another moment.
I use Windows 10.
I started the CMD as administrator, and it solved the problem.
Find CMD, right click, and click open as administrator.
I had an outdated version of npm. I ran a series of commands to resolve this issue:
npm cache clean --force
Then:
npm install -g npm#latest --force
Then (once again):
npm cache clean --force
And finally was able to run this (installing Angular project) without the errors I was seeing regarding EPERM:
ng new myProject
In my case, I was facing this error because my directory and its file were opened in my editor (VS code) while I was running npm install. I solved the issue by closing my editor and running npm install through the command line.
I had the same problem, after updating npm. Solved it by re-installing latest npm again with:
npm i -g npm
but this time with cmd running in administrating mode.
i did all this because i suspected there was an issue with the update, mostly some missing files.
I had the same problem when I tried to install the npm package AVA. The solution for me was to delete the node_modules folder and force-clean the npm cache:
rm -rf node_modules
npm cache clean --force
I could then install the npm package without a problem.
for me it was an issue of altering existing folders in node_module, so i nuked the whole folder and run npm install again. it works with no errors after that
Just run cmd as admin. delete old node_modules folder and run npm install again.
The Problem I faced (In Windows Computer)
When I was trying to install a couple of npm packages I got the following error:
npm - EPERM: operation not permitted - while npm was trying to rename a file
Here's my debug snippet for reference, if you've faced the similar problem:
After carefully checking out the answers from other users, I have created a detailed answer for the community
My Solution for the problem
Follow the mentioned steps
Right-click on the project folder
Go to properties -> Security Tab
Select Users -> Edit
In the Permission for Users section, Full control -> Give a check mark in Allow -> OK
Wait for Windows security to apply the new security rules
Click OK
Visualization of the steps
If you follow these steps and try to install npm packages again it will work properly.
Note: It's a best practice to close and open up the command line again to experience the changes
Simplest way
Hope I am not too late for this post but recently even I too got hit by this issue. And also I had no admin rights on my laptop.
Here is the simplest way I fixed the bug.
Locate the file name .npmrc (it will be in C:\Users\<user name>\.npmrc)
Open it and change the path of prefix= to prefix=C:\Users\<user name>\AppData\Roaming\npm
hope it will be helpful..
Happened to me since the folder/file was locked by another process. Used a tool (LockHunter) to terminate that process and it started working again (possible reason).
If you getting this error in an IDE's terminal/commands prompt, try delete node_modules, close IDE, and run the npm install command again.
The time when IDE started but still not completed its analysis of node_modules tree is a tricky moment, when packages installation may fail because IDE still scanning node_modules contents.
This error is caused by different problems try the below one of them will work for you!
try to run npm as Administrator
Run cmd as administrator npm config edit (You will get notepad editor)
Change Prefix variable to C:\Users\<User Name>\AppData\Roaming\npm
The errors went after I disabled my anti-virus (Avast)
Sometimes a simple cache clear like the below would fix it.
npm cache clear
For me the problem come from bash terminal. I change my terminal to powershell and it's ok.
Really easy to resolve
Find this command npm cache clean as a solution to those error in quick and simple way!
I updated my node version to 8.9.4 and ran the necessary install command again from administrator command prompt. It worked for me!
A reboot of my laptop and then
npm install
worked for me!
Running npm commands in Windows Powershell solved my issue.
Try npm i -g npm . NPM version 6.9 is work to me.
Apparently anti-virus software can also cause this error. In my case I had Windows Security's Ransomware Protection protecting my user folders which caused this error.
Windows 10,
Running the IDE (in my case IntelliJ) in administrator mode and executing npm install does resolves the problem.
If no IDE then run CMD in administrator mode and try executing npm install
For those trying to update config
If having trouble updating your npm config, try instead running using the -g flag. This solved the issue on Win 10 for me after trying everything else.
npm config edit -g
I am able to update the config and changes are reflected everywhere. This may be due to running npm in an organizational scope.
I was running create-react-app server. Simply stopped the server and everything worked just fine.
The simpler way to solve this by entering the below command
npm config set cache C:\tmp\nodejs\npm-cache --global
At least I just solved my problem in this way:
Search cmd
Then run as administrator
Then npm i -g expo-cli or npm config set prefix /usr/local
I just solved my problem.

Categories

Resources