Error: ENOENT: no such file or directory, scandir

141,962

Solution 1

I sometimes also get this error when starting my gulp server. My workaround is to just run:

npm rebuild node-sass

And then gulp starts nicely afterward.

Solution 2

Here's what worked for me

$npm update
$npm install
$node node_modules/node-sass/scripts/install.js
$npm rebuild node-sass

Solution 3

For my case it helps only after doing this command:

node node_modules/node-sass/scripts/install.js

And then there will be /node_modules/node-sass/vendor folder

Solution 4

Some files may not be available in the local version of NodeJS, and sometimes NodeJS does not send a message about it. In this case --force is helpful.

npm install node-sass --force

or

npm rebuild node-sass --force

Solution 5

rebuild node-sass or just reinstall everything in case node-sass rebuild of doesn't work.

npm rebuild node-sass

or

rm -rf node_modules && npm install

or

npm rebuild

or

npm ci

or just delete node_modules manually and package-lock.json and run npm i

Share:
141,962
Dhiresh Budhiraja
Author by

Dhiresh Budhiraja

Developer At HARTRON

Updated on September 03, 2021

Comments

  • Dhiresh Budhiraja
    Dhiresh Budhiraja over 1 year

    I scaffold an app using jhipster which is microservice gateway using cassandra db and using maven to build which was building fine after scaffold.i ran gulp command to for the live reload of ui.

    i made a change slighlty in navbar and home page of it. which was also working file & made some changes in the json files of home & navbar & do some minor changes as adding the search box and other.

    it failed to reload. I stop the gulp & maven & restarted them. maven is building but again not loading the site in localhost

    when i ran gulp it is showing me this error.

     gulp
    fs.js:952
      return binding.readdir(pathModule._makeLong(path), options.encoding);
                     ^
    Error: ENOENT: no such file or directory, scandir '/home/hartron/foodnetteam/codebase/mandi/node_modules/node-sass/vendor'
        at Error (native)
        at Object.fs.readdirSync (fs.js:952:18)
        at Object.getInstalledBinaries (/home/hartron/foodnetteam/codebase/mandi/node_modules/node-sass/lib/extensions.js:121:13)
        at foundBinariesList (/home/hartron/foodnetteam/codebase/mandi/node_modules/node-sass/lib/errors.js:20:15)
        at foundBinaries (/home/hartron/foodnetteam/codebase/mandi/node_modules/node-sass/lib/errors.js:15:5)
        at Object.module.exports.missingBinary (/home/hartron/foodnetteam/codebase/mandi/node_modules/node-sass/lib/errors.js:45:5)
        at module.exports (/home/hartron/foodnetteam/codebase/mandi/node_modules/node-sass/lib/binding.js:15:30)
        at Object.<anonymous> (/home/hartron/foodnetteam/codebase/mandi/node_modules/node-sass/lib/index.js:14:35)
        at Module._compile (module.js:570:32)
        at Object.Module._extensions..js (module.js:579:10)
    

    Could anyone tell me solution for this

  • user3405291
    user3405291 about 5 years
    I was receiving the same error while trying to run a KeystoneJS website with $ node keystone, and your workaround solved the error. Thanks
  • Gunarathinam
    Gunarathinam almost 5 years
    I got the error 'Error: ENOENT: no such file or directory, scandir '**/node_modules/node-sass/vendor', this solution helped me resolve it. Thanks.
  • Jie
    Jie almost 5 years
    Thanks. I have the same problem in Angular project and solved by this command. New "npm install" can't fix my error. It seems a problem in old "node-sass" version. github.com/sass/node-sass/issues/1918
  • lexa-b
    lexa-b over 4 years
    I my case (in linux), it was necessary to pre-download the installer "nodejs node_modules/node-sass/scripts/install.js" then rebuild
  • David Wickstrom
    David Wickstrom over 4 years
    Good to know: I had this problem on my laptop a lot when switching between different versions of node (including different versions of most node packages). I was maintaining 2 versions of a web site from the same laptop. One site was old and based on Angular and the other site was based on React. And this specific problem went away when the old site was finally replaced I no longer had to switch between the two projects on my laptop.
  • lorrainebatol
    lorrainebatol over 3 years
    this works for me, except on line 3 I replaced "nodejs" with just "node"
  • Mukundhan
    Mukundhan almost 3 years
    pre-install scripts are not executed while installing. works for me too. just replaced with the global install directory:)
  • vr_driver
    vr_driver almost 3 years
    node node_modules/node-sass/scripts/install.js also works too.
  • Morten Bak
    Morten Bak over 2 years
    if you for some reason previously has run: npm config set ignore-scripts true then the node binding will not be installed. This was my issues, and running: node node_modules/node-sass/scripts/install.js fixed my issue
  • Osama Ibrahim
    Osama Ibrahim over 2 years
    this worked for me. I am using webpack and I still braintree-dropin when everything stopped working! Thank you!
  • digiwand
    digiwand about 2 years
    yesss. What @vr_driver said. Running just node node_modules/node-sass/scripts/install.js worked for me Thanks for this!
  • webpreneur almost 2 years
    You have literally saved my life.
  • techloris_109
    techloris_109 over 1 year
    using webpack and worked for me. Saved my day, thank you !
  • Gustavo Alexandre about 1 year
    mvn? does it work with node or with java!!
  • Kapil Yadav
    Kapil Yadav 9 months
    Oh Man! How can I owe you a cup of coffee or a beer! I literally tried for whole day and finally your solution worked!