来自 chokidar 的错误(C:) : 错误: EBUSY: 资源忙或锁定,lstat‘ C: DumpStack.log.tmp

使用角度和发球时间,我得到了错误:

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'
231776 次浏览

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;

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

While using @Output(), remove auto imported statement

import { EventEmitter } from 'protractor';

and include import EventEmitter from existing

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

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.

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).

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

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

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.

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!

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

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.

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.

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

Follow these steps:

  1. Delete the "node_modules" folder
  2. Run npm install
  3. Run npm cache clean

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

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 !

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

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.

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

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"

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.

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.

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

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!

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.

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.

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!

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

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.

I know this is probably a bad solution but I fixed this issue by copying all my changes into a notepad and reverted all my changes in VS code - put back my changes and hooray! 'ng build' run without any problems

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.