node-sass: Error: ENOENT: no such file or directory, scandir '**/node_modules/node-sass/vendor'

Followed the troubleshooting guide. I’m having an intermittent build issue with one of our projects. The appearance is that it happens randomly.

See comment for solution

I’m using gulp-sass@2.1.0 which has this as a dependency.

I suspect there might be some sort of concurrency issue with the download of binaries in that specific folder. I’ve tried switching to several different node and npm versions now to see if the problem is related but hasn’t resolved the issue.

Node v4.4.5
NPM 3.5.3
{ http_parser: '2.5.2',
  node: '4.4.5',
  v8: '4.5.103.35',
  uv: '1.8.0',
  zlib: '1.2.8',
  ares: '1.10.1-DEV',
  icu: '56.1',
  modules: '46',
  openssl: '1.0.2h' }
linux
x64

Ubuntu 16.04

On builds that do run successfully, I’ll get the following message before NPM quits


Binary downloaded and installed at /home/jenkins/development/node_modules/node-sass/vendor/linux-x64-46/binding.node
"/home/jenkins/development/node_modules/node-sass/vendor/linux-x64-46/binding.node" exists. 
 testing binary.
Binary is fine; exiting.

Otherwise this error will happen during the build

[01:09:46] 'sass' errored after 16 ms
[01:09:46] Error: ENOENT: no such file or directory, scandir '/home/jenkins/development/node_modules/node-sass/vendor'
    at Error (native)
    at Object.fs.readdirSync (fs.js:808:18)
    at Object.getInstalledBinaries (/home/jenkins/development/node_modules/node-sass/lib/extensions.js:74:13)
    at foundBinariesList (/home/jenkins/development/node_modules/node-sass/lib/errors.js:20:15)
    at foundBinaries (/home/jenkins/development/node_modules/node-sass/lib/errors.js:15:5)
    at Object.module.exports.missingBinary (/home/jenkins/development/node_modules/node-sass/lib/errors.js:45:5)
    at Object.<anonymous> (/home/jenkins/development/node_modules/node-sass/lib/index.js:14:28)
    at Module._compile (module.js:409:26)
    at Object.Module._extensions..js (module.js:416:10)
    at Module.load (module.js:343:32)

npm ERR! Linux 3.13.0-85-generic
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "run-script" "build"
npm ERR! node v4.4.5
npm ERR! npm  v3.5.3
npm ERR! code ELIFECYCLE
npm ERR! lexi@1.0.0 build: `gulp testfail lintfail babel sass hb`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the lexi@1.0.0 build script 'gulp testfail lintfail babel sass hb'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the lexi package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     gulp testfail lintfail babel sass hb
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs lexi
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls lexi
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     /home/jenkins/development/npm-debug.log

Gulp Sass installation doesn’t seem to be catching the Vendor binaries every time even manually installing.


sudo npm install gulp-sass
npm WARN deprecated cross-spawn-async@2.2.4: cross-spawn no longer requires a build toolchain, use it instead!
- lru-cache@4.0.1 node_modules/cross-spawn-async/node_modules/lru-cache
lexi@1.0.0 /home/jenkins/development
├─┬ gulp@3.9.1
│ └─┬ vinyl-fs@0.3.14
│   └─┬ glob-watcher@0.0.6
│     └─┬ gaze@0.5.2
│       └─┬ globule@0.1.0
│         └─┬ minimatch@0.2.14
│           └── lru-cache@2.7.3 
├─┬ gulp-sass@2.3.1
│ └─┬ node-sass@3.7.0
│   ├─┬ cross-spawn-async@2.2.4
│   │ └── lru-cache@4.0.1 
│   ├─┬ gaze@1.0.0
│   │ └─┬ globule@0.2.0
│   │   └─┬ minimatch@0.2.14
│   │     └── lru-cache@2.7.3 
│   └─┬ node-gyp@3.3.1
│     └─┬ minimatch@1.0.0
│       └── lru-cache@2.7.3 
├─┬ jshint@2.9.2
│ └─┬ cli@0.6.6
│   └─┬ glob@3.2.11
│     └─┬ minimatch@0.3.0
│       └── lru-cache@2.7.3 
└─┬ mocha@2.5.3
  └─┬ glob@3.2.11
    └─┬ minimatch@0.3.0
      └── lru-cache@2.7.3 

npm WARN optional Skipping failed optional dependency /chokidar/fsevents:
npm WARN notsup Not compatible with your operating system or architecture: fsevents@1.0.12
npm WARN enoent ENOENT: no such file or directory, open '/home/jenkins/development/node_modules/languages.css/package.json'
mike@lexi3:/home/jenkins/development$ ls node_modules/node-sass/
bin  binding.gyp  lib  node_modules  package.json  README.md  scripts  src

But installing node-sass manually seems to force the binaries to get downloaded

mike@lexi3:/home/jenkins/development$ sudo npm install node-sass@3.4.2
npm WARN deprecated npmconf@2.1.2: this package has been reintegrated into npm and is now out of date with respect to npm
npm WARN deprecated cross-spawn-async@2.2.4: cross-spawn no longer requires a build toolchain, use it instead!

> node-sass@3.4.2 install /home/jenkins/development/node_modules/node-sass
> node scripts/install.js

Binary downloaded and installed at /home/jenkins/development/node_modules/node-sass/vendor/linux-x64-46/binding.node

> spawn-sync@1.0.15 postinstall /home/jenkins/development/node_modules/spawn-sync
> node postinstall


> node-sass@3.4.2 postinstall /home/jenkins/development/node_modules/node-sass
> node scripts/build.js

` /home/jenkins/development/node_modules/node-sass/vendor/linux-x64-46/binding.node ` exists. 
 testing binary.
Binary is fine; exiting.
- lru-cache@4.0.1 node_modules/cross-spawn-async/node_modules/lru-cache
- minimatch@3.0.0 node_modules/node-sass/node_modules/glob/node_modules/minimatch
- glob@7.0.3 node_modules/node-sass/node_modules/glob
- minimatch@0.3.0 node_modules/node-sass/node_modules/globule/node_modules/glob/node_modules/minimatch
- glob@3.2.11 node_modules/node-sass/node_modules/globule/node_modules/glob
- lodash@2.4.2 node_modules/node-sass/node_modules/lodash
- minimatch@0.2.14 node_modules/node-sass/node_modules/minimatch
- globule@0.2.0 node_modules/node-sass/node_modules/globule
- gaze@1.0.0 node_modules/node-sass/node_modules/gaze
- in-publish@2.0.0 node_modules/in-publish
lexi@1.0.0 /home/jenkins/development
├─┬ babel-cli@6.9.0
│ └─┬ request@2.72.0
│   └─┬ bl@1.1.2
│     └── readable-stream@2.0.6 
├─┬ gulp-autoprefixer@3.1.0
│ └─┬ through2@2.0.1
│   └── readable-stream@2.0.6 
├─┬ jshint@2.9.2
│ └─┬ cli@0.6.6
│   └─┬ glob@3.2.11
│     └─┬ minimatch@0.3.0
│       └── lru-cache@2.7.3 
├─┬ mocha@2.5.3
│ └─┬ glob@3.2.11
│   └─┬ minimatch@0.3.0
│     ├── lru-cache@2.7.3 
│     └── sigmund@1.0.1 
└─┬ node-sass@3.4.2 
  ├─┬ cross-spawn@2.2.3 
  │ ├─┬ cross-spawn-async@2.2.4
  │ │ └── lru-cache@4.0.1 
  │ └─┬ spawn-sync@1.0.15 
  │   ├─┬ concat-stream@1.5.1 
  │   │ ├── readable-stream@2.0.6 
  │   │ └── typedarray@0.0.6 
  │   └── os-shim@0.1.3 
  ├─┬ gaze@0.5.2
  │ └─┬ globule@0.1.0
  │   └─┬ minimatch@0.2.14
  │     ├── lru-cache@2.7.3 
  │     └── sigmund@1.0.1 
  ├─┬ node-gyp@3.3.1
  │ └─┬ minimatch@1.0.0
  │   └── lru-cache@2.7.3 
  └─┬ npmconf@2.1.2 
    ├─┬ config-chain@1.1.10 
    │ └── proto-list@1.2.4 
    └── uid-number@0.0.5 

npm WARN optional Skipping failed optional dependency /chokidar/fsevents:
npm WARN notsup Not compatible with your operating system or architecture: fsevents@1.0.12
npm WARN enoent ENOENT: no such file or directory, open '/home/jenkins/development/node_modules/languages.css/package.json'

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Reactions: 57
  • Comments: 60 (5 by maintainers)

Commits related to this issue

Most upvoted comments

Just to update from my end. I found that for some reason no matter what I did even after the permissions issue was resolved, it still wouldn’t always run the install.js script. I also noticed it tends to happen when its only part of a large set of downloads.

As a safe guard, I just started running the install.js file after NPM Install command part of my build. This ensured that the vendor folder was always present.

Can’t explain why the install file doesn’t always get ran on each build. So my build script looks like this:

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

npm will only execute install scripts for direct dependencies in your package.json. This is a performance optimisation on their end which is unfortunate.

npm rebuild node-sass is the official solution. Deleting your node_modules and running npm install will also do the trick.

This commonly happens in CI systems because they’ll typically run npm install with the default OS Node. Later in their script they’ll switch a new version of Node. Native extension are compiled against the version of Node that npm was using during install. This means the new Node cannot see the extension built during install.

In this case, running npm install again doesn’t fix the issue because npm thinks it is installed. This is why you must run npm rebuild node-sass.

@peterpme I was able to fix this on heroku by turning off NODE_MODULES_CACHE

heroku config:set NODE_MODULES_CACHE=false

npm rebuild node-sass

I have same problem, run npm rebuild node-sass resolve it.

npm rebuild node-sass fixed the issue for me.

The vendor directory is created during npm install. Try deleting your node_modules and running npm install. On 22 Jun 2016 2:02 AM, “dustin-page” notifications@github.com wrote:

Note your Gulp-Sass installation referenced above is installing: node-sass@3.7.0

But when you do it manually you are installing: node-sass@3.4.2

Version 3.4.2 doesn’t have “vendor” in the “files” array I referred to in previous comment, but version 3.7.0 does.

package.json version 3.4.2: “files”: [ “bin”, “binding.gyp”, “lib”, “scripts”, “src” ],

package.json version 3.7.0: “files”: [ “bin”, “binding.gyp”, “lib”, “scripts”, “src”, “vendor” ],

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/sass/node-sass/issues/1579#issuecomment-227487362, or mute the thread https://github.com/notifications/unsubscribe/AAjZWIJUYcMtWAKcDWs5fXNLpdHbggo7ks5qOArvgaJpZM4Ivk6Q .

Hi everybody,

When deploying to Heroku, I continue to have this issue even after running npm rebuild node-sass. Does anybody else feel the same way?

It appears that there was a permissions issue running install.js.

I’m not sure why it was doing it intermittently, but I simply changed the access rights to the build folder.

NPM seems to not give you a notification if install.js fails to run correctly.

I had this issue trying to deploy to Heroku after I started to import some css inside JS packs with Webpacker which uses Yarn. npm rebuild node-sass did help, and one way to make it work during Heroku deployment is to put this to package.json:

  "scripts": {
    "postinstall": "npm rebuild node-sass"
  }

npm rebuild node-sass

I have same problem, run npm rebuild node-sass resolve it.

I have the same problem, and after: sudo npm rebuild node-sass It was the solution to the problem…

We’ve just started having this issue intermittently on our build servers using Yarn 0.18.1. Our build was previously stable; we’re having a hard time figuring out what’s changed. Just posting here in case anyone else is also suddenly encountering this issue too.

Update: Our problem seems to be https://github.com/yarnpkg/yarn/issues/1832

@mrking

nodejs node_modules/node-sass/scripts/install.js npm rebuild node-sass

I ran this for every package that gave ENOENT and now everything if working. thanks alot!

for some reason the install script wasn’t invoked when i ran npm install

Use npm install node-sass or Linux npm install node-sass --no-bin-links

This problem was happening on a build server where the folder was clean on each build. So your suggestion of deleting the node_modules folder didn’t fix the issue in my case as there wasn’t a node_modules folder to begin with.

I don’t know enough about how NPM works to comment on your bit of information. If you want me to do any additional logging, I can still reproduce the problem fairly consistently. However, I have my work around for now 👍

However, seeing no one else has reported this until now, whatever it is, its not widespread. Probably not good utilization of time.

npm rebuild node-sass resolved it for me too.

Every 19 out of 20 deployments on heroku for my apps that use this package simply crash due to this problem 😃 I keep pushing the same commit until Heroku builds it. That seems to be the only solution right now, yes? Rebuild until it works?

Vagrant box can use: npm rebuild node-sass --no-bin-links Thank for this topic.

Simlar problem with node-sass v3.7.0. I get the following error: Error: ENOENT: no such file or directory, scandir ‘C:\Working\my-app\node-sass\vendor’

In the package.json file it is looking for the “vendor” directory, which doesn’t exist:

“files”: [ “bin”, “binding.gyp”, “lib”, “scripts”, “src”, “vendor” ],

Rolling back “node-sass” to “3.4.0” temporarily fixed the issue for me. However, I am now locked into this version.

Same issue suddenly appeared magically in Dockerfile builds. Downgraded npm 6.6 to 6.5 and then it worked again.

The workaround fix by @devmedios worked for our Docker CI pipeline. 😅 npm i node-sass --no-bin-links Thanks!

This problem started appearing after rebuilding our docker image today (no change to Dockerfile content), reverting back to old docker image works.

the docker file looks like this:

FROM node:8.9-slim

RUN apt-get update && \
  apt-get install -y --no-install-recommends git mysql-client openssh-client \
          python \
          libcairo2-dev libjpeg-dev libpango1.0-dev libgif-dev build-essential g++ \
          libpng-dev && \
  npm i -g yarn lerna && \
  rm -rf /var/lib/apt/lists/*

so the problem is one of the following:

  • node / npm
  • yarn
  • lerna
  • other OS packages

The weird thing is, even after fixing the version of yarn and lerna, the problem still exists:

npm i -g yarn@1.12.3 lerna@3.4.3 && \

node-sass & bug

Module build failed: Error: ENOENT: no such file or directory, scandir 'node_modules\node-sass\vendor'

image

solution

delete node_modules folder & re-install all modules

OR

delete package.json "node-sass": "^4.7.2", & re-install npm i -D node-sass@4.7.2

OK

image

I had the same issue. My installed version for node-sass was 3.1.0. I upgraded it to 3.7.0 which contains vendor files and now it is working fine.

Deleting node_modules/node-sass and reinstalling didn’t seem to work for me. @ERPedersen’s solution worked.

I ran into this problem with node 8.5.0 and node-sass 4.5.3. Fixed it by deleting the node_modules/node-sass directory and reinstalling.

But exactly what is the cause of the problem?

Thank you @mrking, simply npm rebuild node-sass did the trick here (MacOS)

@pencilcheck - I was running into the same issue. Add

npm rebuild node-sass &&

Before your build/start script for heroku and it’ll recompile node sass before building your app packages.

The only thing I had to do on TravisCi was:

script:
- npm rebuild node-sass
- npm run build

After that it worked, thanks

npm rebuild works sometimes. The only thing that always works for me to get rid of this ridiculous annoying bug is to just go npm install node-sass@random-compatible-different-version

Had the same problem. After running

npm update

Everything worked fine