Node-sass: Should automatic compile if download failed.

Created on 11 Jan 2017  Â·  16Comments  Â·  Source: sass/node-sass

  • NPM version (npm -v): 3.10.10
  • Node version (node -v): v6.9.4
  • Node Process (node -p process.versions):
{ http_parser: '2.7.0',
  node: '6.9.4',
  v8: '5.1.281.89',
  uv: '1.9.1',
  zlib: '1.2.8',
  ares: '1.10.1-DEV',
  icu: '56.1',
  modules: '48',
  openssl: '1.0.2j' }
  • Node Platform (node -p process.platform): linux
  • Node architecture (node -p process.arch): x64
  • node-sass version (node -p "require('node-sass').info"):
node-sass   3.13.1  (Wrapper)   [JavaScript]
libsass     3.3.6   (Sass Compiler) [C/C++]
  • npm node-sass versions (npm ls node-sass):
[email protected] /home/fengyu/projects/linchang/customer-client-wx
└─┬ [email protected]
  └── [email protected] 
 npm install node-sass

> [email protected] install /home/fengyu/node_modules/node-sass
> node scripts/install.js

Downloading binary from https://github.com/sass/node-sass/releases/download/v4.2.0/linux-x64-48_binding.node
Cannot download "https://github.com/sass/node-sass/releases/download/v4.2.0/linux-x64-48_binding.node": 

ESOCKETTIMEDOUT

Hint: If github.com is not accessible in your location
      try setting a proxy via HTTP_PROXY, e.g. 

      export HTTP_PROXY=http://example.com:1234

or configure npm proxy via

      npm config set proxy http://example.com:8080

> [email protected] postinstall /home/fengyu/node_modules/node-sass
> node scripts/build.js

Binary found at /home/fengyu/node_modules/node-sass/vendor/linux-x64-48/binding.node
Testing binary
Bus error
npm WARN enoent ENOENT: no such file or directory, open '/home/fengyu/package.json'
npm WARN fengyu No description
npm WARN fengyu No repository field.
npm WARN fengyu No README data
npm WARN fengyu No license field.
npm ERR! Linux 4.4.0-59-generic
npm ERR! argv "/usr/bin/nodejs" "/usr/bin/npm" "install" "node-sass"
npm ERR! node v6.9.4
npm ERR! npm  v3.10.10
npm ERR! code ELIFECYCLE

npm ERR! [email protected] postinstall: `node scripts/build.js`
npm ERR! Exit status 135
npm ERR! 
npm ERR! Failed at the [email protected] postinstall script 'node scripts/build.js'.
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 node-sass package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node scripts/build.js
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs node-sass
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls node-sass
npm ERR! There is likely additional logging output above.

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

Maybe it's better to compile from source if download fail, just like many other packages.

Invalid - Not Reproducible npm build

All 16 comments

Sorry, you didn't follow the issue template, so we can't help you.

Hi @nschonni . I've modified my issue to fit for issue template.

@abcfy2 thanks. From your output there looks like 2 different versions going on there (3.13.1 and 4.2.0).

Since it output https://github.com/sass/node-sass/blob/1e76d99164a112a8895c668af795594a35dcdca6/scripts/build.js#L210

Testing binary

It means it did fall back to the build process after the attempted download, but ran into an issue trying to test the partial download

Bus error

My project depends on angular-cli, which is used [email protected]. I try to install the lastest version of node-sass, but the same issue occured.

What I want to make clear here is that sometimes downloading is not complete, thus Testing binary failed. In this scenario, node-sass should also try to compile from source, not fail exit immediately.

This looks like a bug, probably related to the recent changes. If the binary test fails we should fallback to building locally. However if the download fails with getting any content, like a 404 or proxy error I don't believe we fallback to a local compile.

Most 404 are because the binary doesn't exist for the node + node-sass version combination. In these cases the binary compilation fails which generates a lot of support noise for us.

@nschonni I think you're mistaken. The binary test happens after the download. After which a local build should have happened but didn't. So for some reason build bailed out without compiling the binary. A rough guess would be that build saw the binary on disk and exited early, but I'm not able to check the code atm.

I've taken a closer look at this at we've run into this before. The problem is with the binary test. Loading a broken binary can cause Node to fatally exit which prevents us catching the error calling build.

I think the only way to guard around this is to not flushed the binary to disk until the download has completed.

@xzyfer sounds resonable. Maybe try a little cleanup before calling the callback here https://github.com/sass/node-sass/blob/master/scripts/install.js#L37

Has anyone fixed this problem?

I think the only safe fix would be to run a require thing in a separate node subprocess.

@saper is right. We could spawn a process and check it's exit code instead of requireing like we currently do.

And also, I think it better to cache compiled binary as well. So that we don't have to compile again and again if removed node-modules/ directory, just like the downloaded pre-compile binary.

@abcfy2 please limit off topic comments. We already cache the binary in the npm cache directory.

Really? But I found that the compiled binary was not cached.

$ export SKIP_SASS_BINARY_DOWNLOAD_FOR_CI=1
$ npm install node-sass

> [email protected] install node_modules/node-sass
> node scripts/install.js

Skipping downloading binaries on CI builds

> [email protected] postinstall node_modules/node-sass
> node scripts/build.js

Building: /usr/bin/nodejs 
... SNIP ...

But when I delete the node-modules, would be compiled again.

rm -fr node-modules
npm install node-sass
... compiled again ...

That's because you have used SKIP_SASS_BINARY_DOWNLOAD_FOR_CI which changes a bunch of behaviour. The SKIP_SASS_BINARY_DOWNLOAD_FOR_CI is an internal flag for our CI process which should not be used under any circumstances.

This flag will disappear at any moment #1453.

Stale report, please reopen with the new information if the problem still persists in 4.12.0

Was this page helpful?
0 / 5 - 0 ratings