93

Using Angular and during ng serve, I'm getting the error:

Error from chokidar (C:\): Error: EBUSY: resource busy or locked, lstat 'C:\DumpStack.log.tmp'
Error from chokidar (C:\): Error: EBUSY: resource busy or locked, lstat 'C:\hiberfil.sys'
Error from chokidar (C:\): Error: EBUSY: resource busy or locked, lstat 'C:\pagefile.sys'
Error from chokidar (C:\): Error: EBUSY: resource busy or locked, lstat 'C:\swapfile.sys'
Post Impatica
  • 14,999
  • 9
  • 67
  • 78
  • 27
    I had something similar and it was because someone had added an npm package and I hadn't `npm install` after pulling their changes. – stubbzarelli Jul 29 '20 at 12:27
  • 43
    Why is npm/chokidar/whatever trying to do anything with my swapfile anyways? That's... rather alarming. – Paul Aug 26 '20 at 19:55
  • @stubbzarelli +1 your comment helped me to solve this issue. Thanks. – velsorange Oct 01 '20 at 07:20
  • 3
    @Paul is right, this is a very red flag even if it's an honest bug – Pieter De Bie Nov 12 '20 at 08:03
  • @paul "rather alarming" -- yep, warrants disciplinary action. – bvj Dec 23 '20 at 04:31
  • @Paul Could you explain why this is so alarming? Chokidar uses the filesystem module from Node.js, which in turn talks to the OS. Could it be that it's just the operating system managing virtual memory allocation that sends this error back to Node? – Melvin Koopmans Jan 14 '21 at 09:16
  • 6
    @MelvinKoopmans `chokidar` is a file-watcher and there's no good reason for anything to be watching root-directory files, let alone system files like those. All the answers blaming VS Code have it wrong, something appears to be screwy with `chokidar` if you ask me. (I get this running things like `webpack serve` from the command line, no editors involved -- but as many answers state, it seems to be a side-effect of other errors.) – McGuireV10 Jan 15 '21 at 09:51
  • @MelvinKoopmans What McGuireV10 said. I don't know if this is just the OS throwing a red herring error or not, but I would really like confirmation that npm packages are not poking around in the file system outside of their project root. – Paul Jan 15 '21 at 15:58
  • I've added an answer below but it appears to be an issue with passing a path to a directory that doesn't exist to chokidar. In my case it was incorrectly passing '/public'. I suspect that as it couldn't find C:/public it was doing a watch on C:/ hence all the lock errors on files that it can't access that sit in the root of the C:/ – theirongiant Dec 19 '22 at 20:02

34 Answers34

71

I get this whenever I'm using VSCode and I add something similar to a component:

@Output() somename = new EventEmitter();

...and I let VSCode auto-import the supporting module. Instead of adding EventEmitter to the existing @angular/core, VSCode adds a new import to protractor which causes the error.

If you are getting this error and can't remember where the last changes were made, try searching for from 'protractor' in your code;

Post Impatica
  • 14,999
  • 9
  • 67
  • 78
32

This can happen after several different build errors. For some reason the build summary fails to report the original error and reports this instead.

(Incidentally I see the OP was using Angular and ng serve; I'm getting this in React using npm start. So I'm guessing it could happen in VS Code using any toolchain.)

I was getting this output in the VS Code terminal:

i 「wdm」: Failed to compile.
Error from chokidar (C:\): Error: EBUSY: resource busy or locked, lstat 'C:\hiberfil.sys'
Error from chokidar (C:\): Error: EBUSY: resource busy or locked, lstat 'C:\pagefile.sys'
Error from chokidar (C:\): Error: EBUSY: resource busy or locked, lstat 'C:\swapfile.sys'

After looking for answers on this page and elsewhere, I found nothing that worked for me.

But when I scrolled back in the VS Code terminal, I found this build error:

ERROR in ./Components/ServiceBooking/ServiceBooking/ServiceBooking.tsx
Module not found: Error: Can't resolve 'components/Common/BookingComponents/BookingTypeSelector/BookingTypeSelector' in [...]

That was a casing error in an import auto-added by VS Code. I don't know why but VS Code does that sometimes. Maybe there is something we can tweak in this project to help VS Code not to do that. Anyway, it was an error, and once I fixed it by changing "components" to "Components" in the import, the secondary errors about hiberfil.sys, pagefile.sys and swapfile.sys went away.

The moral of the tale: beware of the build summary masking build errors. Any time you hit a weird build error, first scroll back through the detailed build output to make sure you are chasing the right error (the original error, rather than a secondary error like this one).

Reg Edit
  • 6,719
  • 1
  • 35
  • 46
21

check for the missing dependencies in package.json

I am using vue js I was trying to run a project and I had this error this problem was because the other developer used a global dependencies and it was not included in my node_modules folder

Nashaat Mohamed
  • 341
  • 2
  • 6
  • 1
    I had this same error at a React project and missing dependency from `package.json` was the reason. – Enes Kirimi Dec 17 '20 at 10:07
  • 1
    What about if this happens right after creating a new vue js project and installing 2 dependencies and 2 plugins via the vue ui? It is completly local and still throws this error right after fresh setup and installation of sass-loader, node-sass, vuex and vue-router. I cant seem to find an answer. – BrOsCoRe Feb 19 '21 at 14:52
  • 1
    confirming, npm install solved my problem with angular 11 app. – Janatbek Orozaly Jun 07 '21 at 22:12
21

Just write npm install , it is a file viewer that warns that a dependency is not properly updated. Without reading the hidden comment among the thousands I would never have known

Solution:

npm install
nart
  • 1,508
  • 2
  • 11
  • 24
Ezequiel Miceli
  • 221
  • 2
  • 2
14

Follow these steps:

  1. Delete the "node_modules" folder
  2. Run npm install
  3. Run npm cache clean
D M
  • 5,769
  • 4
  • 12
  • 27
6

If you are using polyfills, this error will occur if you activated the following polyfill (from src/polyfills.ts):

/** IE10 and IE11 requires the following for NgClass support on SVG elements */
import 'classlist.js';  // Run `npm install --save classlist.js`.

...and did not run the corresponding npm install:

npm install --save classlist.js
Martin Åhlin
  • 2,730
  • 1
  • 20
  • 27
  • Also if you updated core-js from v2 to v3 and still have imports in the v2 format in your polyfills file. – rooby Feb 18 '21 at 06:56
4

Had this in VueJs (2) - installed a module, then uninstalled it (npm uninstall <module_name>) and forgot to delete the "import <module_name>" from the .vue file. Silly but there it was.

Thingamabobs
  • 7,274
  • 5
  • 21
  • 54
3

While using @Output(), remove auto imported statement

import { EventEmitter } from 'protractor';

and include import EventEmitter from existing

import { Component, OnInit,EventEmitter } from '@angular/core';

Menuka Ishan
  • 5,164
  • 3
  • 50
  • 66
Antony
  • 39
  • 3
2

EventEmitter() by default imported by protractor in VS code,

import { EventEmitter } from 'protractor'; remove this and import from core.

import { EventEmitter } from '@angular/core';

this solves the other issue as well which is expecting 0 arguments and have 1.

Boken
  • 4,825
  • 10
  • 32
  • 42
2

I had the same issue and I fixed via setting in package.json

"browser": {
  "http": false
}

How to insert in package.json

{
  "name": "App Name",
  "version": "0.0.0",
  "scripts": {
     // --------
  },
  "dependencies": {
     // --------
  },
  "devDependencies": {
     // --------
  },
  "browser": {
    "http": false
  }
}

If someone knows its reason that why is it necessary and what happens by adding this then please add some description to make reading more sensible. Thanks

WasiF
  • 26,101
  • 16
  • 120
  • 128
2

I got this error while install Material UI designs in my react project, and after installing npm package i have no issues now.

Add:

npm i

Thanks!

Gopalakrishnan T
  • 453
  • 1
  • 4
  • 14
1

I had the same error because phpStorm/WebStorm added this import

import {forEach} from 'ag-grid-community/dist/lib/utils/array';

just remove it and the problem was gone!

Christophe Le Besnerais
  • 3,895
  • 3
  • 24
  • 44
1

I had the same issue. My colleague had installed this dependency and I simply restored packages (right click on package.json - Restore Packages) in packages.json and it seemed to fix it.

Robgit28
  • 268
  • 4
  • 18
1

I got similar issue when building an ionic application. I had some similar pages and components from other application reused in this one. Once running, I receveived the message[ng] Error from chokidar (C:\): Error: EBUSY: resource busy or locked, lstat 'C:\pagefile.sys. This was solved by installing a missing library. The error was presented on vscode terminal, a little bit above the message presented on the screen. I felt silly because the error was there since the beginning and I haven´t realized I should have search for it.

Dharman
  • 30,962
  • 25
  • 85
  • 135
Luiz
  • 57
  • 3
1

Yes, I also had a same error..
enter image description here

SOLUTION

It means there's some packages are not installed in your node_module. so just run this command.

npm install  

And then serve again your project !

Rohit Tagadiya
  • 3,373
  • 1
  • 25
  • 25
1

In my case, I was facing the same issue. What I guess is, this arises due to circular dependency. I used a service that was injected in multiple components and I was retrieving all that components simultaneously. It was throwing error resource busy.... I resolved it by providing service in root instead of multiple lazy loaded modules. May be helpful for someone

Analyst
  • 751
  • 6
  • 15
1

I had the same issue today and am using VueJS 3 and VS Code. Somehow my @vue/cli-service was downgraded from 4.5.0 to 3.5.3. No idea how that happened. Anyway, by updating package.json with the following and running npm install after that, it was solved.

"@vue/cli-service": "^4.5.13"
Eugene
  • 173
  • 1
  • 10
1

In my case, the problem was randomly added import by VS CODE auto-complete. So search for the dependency and remove if it is not in use.

  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Dec 28 '21 at 12:36
1

The root cause of this is a directory that does not exist being passed to chokidar. Run 'node ls chokidar' to get a list of packages you are using that use chokidar, then double check any paths you are setting in any config files that might be being used by these packages. In my case it was due to me setting the static option for webpack-dev-server to '/public' rather than path.join(__dirname, 'public') in my webpack config.

edit After looking into it further if you pass a path that doesn't exist to chokidar it will look down the path and start watching the first directory it finds that exists. In the case where that is C:/ then these EBUSY errors will occur against system protected files found there.

theirongiant
  • 171
  • 2
  • 8
0

I needed to re-install the npm packages that were showing later in the error logs (in my case bootstrap and react-router-dom)

Patricia
  • 2,885
  • 2
  • 26
  • 32
0

For Vue.js, Check if you have import like this import Vue from "*.vue"; change it to import Vue from "vue"; It was auto imported by VsCode

Pranoy Sarkar
  • 1,965
  • 14
  • 31
0

This bug is related to Babel and it's preset, I know the screenshot is related to NuxtJS but this npm command solves the problem for Angular as well, since they are using almost the same configuration.

for npm:

npm i -S core-js@2.5.7

for yarn:

yarn add core-js@2.5.7


                                                                                                           
  • core-js/core/dict in ./node_modules/babel-loader/lib??ref--2-0!./node_modules/vue-loader/lib??vue-loader-options!./pages/index.vue?vue&type=script&lang=js&

To install it, you can run: npm install --save core-js/core/dict

WARN Error from chokidar (C:): Error: EBUSY: resource busy or locked, lstat 'C:\DumpStack.log.tmp'

enter image description here

Ali.Ghodrat
  • 3,348
  • 3
  • 31
  • 31
0

I got this error while using angular multi-project setup. I was using firebase functions in my project. The cause of my issue was having a source file located under "projects/my-project/src/app/*" import another file located under "projects/my-project/functions/src*". The functions folder was a sub project folder and had it's own "node_modules" folder.

SOLUTION

So I searched for all import references under "projects/my-project/functions/src*" containing "/functions/". I was using Web Storm but most modern IDE's and text editors like vscode have this capability.

Red
  • 26,798
  • 7
  • 36
  • 58
A Johnson
  • 1
  • 2
0

I had the same issue, and my resolution was to change absolute path when including components (added automatically by VS Code), to relative path, and issue gone.

Changed from:

import { FirebaseCrudService } from 'app/src/firebase/crud/firebase-crud.service';

to:

import { FirebaseCrudService } from '../../firebase/crud/firebase-crud.service';

and it worked.

dzona
  • 3,323
  • 3
  • 31
  • 47
0

In my case this errors were totally unrelated to chokidar. The build has failed because someone did a commit with errors and before even trying to compile i ran "ng serve" I couldn't see the errors.

Either scroll up to see the errors or make a "ng build" before serving so you can see what to fix.

Ruben Miquelino
  • 977
  • 9
  • 13
  • to be on safe side you can use `ng build --prod` in `pre-push` hook in package.json as `"husky": {"hooks":{"pre-push": "ng build --prod"}},` – Analyst Sep 02 '21 at 05:22
0

The solution for me: There's a problem with 2 developers installing dependencies in project using npm and yarn. I use yarn, so:

rm package-lock.json //deleting the package-lock.json  
rm -rf node_modules //deleting the node_modules
yarn //installing the dependencies with yarn
yarn cache clean //cleaning the cache
yarn serve //run the project
Edinho Rodrigues
  • 354
  • 4
  • 24
0

In Linux this type of errors happen when chokidar doesn't get enought file watchers from the system. Thus, increasing then in the system (or reduce the number of files whatched on the project) solves the problem.

The question here is how to do this on Windows.

vanderdill
  • 162
  • 2
  • 14
0

I had a similar problem with my cypress runner. I was getting the following error:

Error from chokidar (C:): Error: EBUSY: resource busy or locked, lstat 'C:\DumpStack.log.tmp'

What happened was that VS automatically put a line on top of my code that read:

const { each } = require("cypress/types/bluebird")

I just removed it from my code and it worked fine. Hope that will help a lot of y'all!

ITselect
  • 133
  • 1
  • 1
  • 10
0

Vue/Nuxt.js

I got this same error in vue/nuxt js application, it happened because of mix package manager that leads to unsynchronized lock files, it is advised not to mix package manager in order to avoid resolution inconsistencies caused by unsynchronized lock files.

enter image description here

enter image description here

Solution: Delete node_modules folder and use npm/yarn depending upon what you used to generate lock file

Anurag Tripathi
  • 784
  • 1
  • 13
  • 13
0

It happened to me when I imported the MatSlideToggle class from:

import {MatSlideToggle} from '@angular/material/slide-toggle/slide-toggle'; 

instead of import it from:

import {MatSlideToggle} from '@angular/material/slide-toggle';

I changed it and now everything works well.

  • This does not really answer the question. If you have a different question, you can ask it by clicking [Ask Question](https://stackoverflow.com/questions/ask). To get notified when this question gets new answers, you can [follow this question](https://meta.stackexchange.com/q/345661). Once you have enough [reputation](https://stackoverflow.com/help/whats-reputation), you can also [add a bounty](https://stackoverflow.com/help/privileges/set-bounties) to draw more attention to this question. - [From Review](/review/late-answers/31834946) – Sumit Sharma May 27 '22 at 12:17
0

As simple as this might seem - I fixed this issue by reverting/discarding the changes I had in my solution - Alternatively you can save your changes into a notepad if you have a lot of changes that you might not want to lose (you can alway put your chnages back). As the result, 'ng build' ran without any problems.

  • As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Jul 20 '22 at 20:11
0

For Vue, here are the steps to follow:

  1. Run npm install
  2. npm run serve

Notes: npm install will audit packages and add necessary packages if needed. Hope it will help.

0

The issue can be related to cache. Here is what works

Delete node_modules directory

Delete package-lock.json

Run npm install

Now it should work!

Zafrullah Syed
  • 1,170
  • 2
  • 15
  • 38
0

By mistake I import Router module from 'express' like this:

import { Router } from 'express';

It should be import from '@angular/router' like this:

import { Router } from '@angular/router';

For you there could be different module which not correctly imported, so you can check lastly added some module's path.