Shopify / buy-button-js

BuyButton.js is a highly customizable UI library for adding ecommerce functionality to any website.

Home Page:http://shopify.github.io/buy-button-js/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

build error related to node-sass

amcc opened this issue · comments

commented

I'm getting the following error (node v10.16.1):

gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/Users/alistairmcclymont/Sites/tutorials/level-up-tuts/level-up-shopify/node_modules/node-gyp/lib/build.js:262:23)
gyp ERR! stack     at ChildProcess.emit (events.js:198:13)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:248:12)
gyp ERR! System Darwin 17.5.0
gyp ERR! command "/usr/local/Cellar/node/11.14.0/bin/node" "/Users/alistairmcclymont/Sites/tutorials/level-up-tuts/level-up-shopify/node_modules/node-gyp/bin/node-gyp.js" "rebuild" "--verbose" "--libsass_ext=" "--libsass_cflags=" "--libsass_ldflags=" "--libsass_library="
gyp ERR! cwd /Users/alistairmcclymont/Sites/tutorials/level-up-tuts/level-up-shopify/node_modules/node-sass
gyp ERR! node -v v10.16.1
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok 
Build failed
npm WARN ts-pnp@1.1.2 requires a peer of typescript@* but none is installed. You must install peer dependencies yourself.

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! node-sass@3.8.0 postinstall: `node scripts/build.js`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the node-sass@3.8.0 postinstall script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/alistairmcclymont/.npm/_logs/2019-08-05T19_37_47_345Z-debug.log````
commented

i've tried installing nvm and using versions 8, 10, 12
I have followed advice here: https://codeforgeek.com/make-failed-with-exit-code-2/

It seems to be an error related to node sass 3.8.0. I can install the latest version of node sass without issue, but not 3.8.0 which this package requires.

hope someone can help

commented

A colleague had installed this successfully on his machine. node v 11.3.0 npm v 6.4.1
I've replicated this using nvm but can't install.
I've also tried getting the script to use the latest version of node-gyp, as described here:
https://github.com/nodejs/node-gyp/wiki/Updating-npm's-bundled-node-gyp

this doesn't alter the node-gyp version when installing.

Can anyone offer any suggestions?

commented

I think the error may be related to not downloading node-sass, this just before the build starts

node-sass is not downloading with a 404 error, everything else downloads fine. This is possibly related to node-sass only supporting older versions of node here:
https://github.com/sass/node-sass/blob/master/TROUBLESHOOTING.md#installation
https://github.com/sass/node-sass/releases/tag/v3.8.0

> node-sass@3.8.0 install /Users/alistairmcclymont/Sites/tutorials/level-up-tuts/endOf17/node_modules/@shopify/buy-button-js/node_modules/node-sass
> node scripts/install.js

Cannot download "https://github.com/sass/node-sass/releases/download/v3.8.0/darwin-x64-72_binding.node": 

HTTP error 404 Not Found

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

> node-sass@3.8.0 postinstall /Users/alistairmcclymont/Sites/tutorials/level-up-tuts/endOf17/node_modules/@shopify/buy-button-js/node_modules/node-sass
> node scripts/build.js

Building: /Users/alistairmcclymont/.nvm/versions/node/v12.8.0/bin/node /Users/alistairmcclymont/Sites/tutorials/level-up-tuts/endOf17/node_modules/node-gyp/bin/node-gyp.js rebuild --verbose --libsass_ext= --libsass_cflags= --libsass_ldflags= --libsass_library=
gyp info it worked if it ends with ok
...
commented

I believe I've got to the root of the problem. I think that node-sass causing the install to fail in my case because of a permissions issue. This can also cause a 404 error in the download process as posted above.

using NVM to install the project with node v.7 did create a successful install. However this isn't ideal, i'm using it in a gatsby project which requires node > 8. But i was able to get round this by updating after the initial install (though I then had to reinstall 'sharp' and i'm guessing there's a few errors to be found down the line. Plus if node_modules is removed and the package reinstalled it would fail again)

I found the issue I believe though. It was to do with a $PATH variable being set on my system (OSX) in .bash_profile. To get MAMP to work when working with PHP composer and drush in drupal projects I had the following lines:

export PATH=/Applications/MAMP/Library/bin/:$PATH
export MAMP_PHP=/Applications/MAMP/bin/php/php7.1.8/bin
export PATH="$MAMP_PHP:$PATH"
export PATH=$PATH:/usr/local/bin

I'm not an expert in this so am unsure which lines might offend node above. However I commented them all out. I completely unistalled all versions of node / npm / nvm. Then reinstalled the current stable version of node from here: https://nodejs.org/en/download/

The project then installed normally. Problem solved.

To conclude if someone is able to comment on this I would be very grateful. I have successfully installed hundreds of node projects previously with the above lines in my .bash_profile without issue. I have also installed newer versions of node-sass without issue. Is there an underlying issue with the version of node-sass used in this project? Also if anyone can comment on the $PATH lines I had and whether there's something drastically wrong with this I'd be grateful, my solution has obviously now caused an issue with composer projects and MAMP usage!

Hi @amcc - thanks so much for the detail debug and explanation! We're currently working on updating the packages for this project and will be releasing it shortly. Also, this relates to #432

We've updated our dependencies in v0.12.0 . Please update to the new version since it should fix this issue.

I should deliver you a bad new:
"@shopify/buy-button-js": "^2.1.0",

Has the same issue on Windows 10 with Visual Studio 2019

What I have here:

C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Microsoft\VC\v160\Microsoft.CppBuild.targets(382,5): error MSB8020: The build tools for Visual Studio 2017 (Platform Toolset = 'v141') cannot be found. To build using the v141 build tools, please install Visual Studio 2017 build tools.

The problem happens with only shopify npm :( Advice needed

commented

Try running this and then try again, worked for me.

npm install --global --production windows-build-tools