Deploy fails when a node module is installed from GitHub instead of NPM

Site: cyclos-app.netlify.app

My package.json installs a node module from GitHub . This module has a prepare script which builds the module during installation. This is a necessary step for github based installs.

"@project-serum/swap-ui": "github:secretshardul/swap-ui#export-components"

Here’s the module repository: swap-ui/package.json at 879d77a9515c3707b3999e41004af95c156f2143 · secretshardul/swap-ui · GitHub

"prepare": "yarn build"

The issue is that my package uses NPM, whereas the prepare script calls Yarn. I have Yarn installed on my local PC so builds work, but they fail on Netlify.

What I’ve already tried:

  1. Changing build script to npm i -g yarn && npm run build.
  2. Setting NETLIFY_USE_YARN as true in environment variables.

The issue is resolved if prepare script is changed to npm run build. However the yarn based script is present in the main branch, so I do not want this approach.

Error

9:14:31 PM: Build ready to start
9:14:33 PM: build-image version: 0582042f4fc261adc7bd8333f34884959c577302
9:14:33 PM: build-image tag: v3.7.6
9:14:33 PM: buildbot version: 00e794c8abfdf634e411d5afc169b41bd6a2f9f3
9:14:33 PM: Fetching cached dependencies
9:14:33 PM: Starting to download cache of 156.8MB
9:14:34 PM: Finished downloading cache in 1.133779275s
9:14:34 PM: Starting to extract cache
9:14:40 PM: Finished extracting cache in 6.407906431s
9:14:40 PM: Finished fetching cache in 7.575270036s
9:14:40 PM: Starting to prepare the repo for build
9:14:41 PM: Preparing Git Reference refs/heads/prod
9:14:42 PM: Parsing package.json dependencies
9:14:42 PM: Starting build script
9:14:42 PM: Installing dependencies
9:14:42 PM: Python version set to 2.7
9:14:43 PM: Started restoring cached node version
9:14:45 PM: Finished restoring cached node version
9:14:46 PM: v12.18.0 is already installed.
9:14:46 PM: Now using node v12.18.0 (npm v6.14.4)
9:14:46 PM: Started restoring cached build plugins
9:14:46 PM: Finished restoring cached build plugins
9:14:46 PM: Attempting ruby version 2.7.1, read from environment
9:14:48 PM: Using ruby version 2.7.1
9:14:48 PM: Using PHP version 5.6
9:14:48 PM: Started restoring cached node modules
9:14:48 PM: Finished restoring cached node modules
9:14:48 PM: Installing NPM modules using NPM version 6.14.4
9:15:56 PM: npm WARN read-shrinkwrap This version of npm is compatible with lockfileVersion@1, but package-lock.json was generated for lockfileVersion@2. I'll try to do my best with it!
npm ERR! prepareGitDep 1>
9:15:56 PM: npm ERR! prepareGitDep > bufferutil@4.0.3 install /opt/buildhome/.npm/_cacache/tmp/git-clone-74f34f89/node_modules/bufferutil
9:15:56 PM: npm ERR! prepareGitDep > node-gyp-build
9:15:56 PM: npm ERR! prepareGitDep
9:15:56 PM: npm ERR! prepareGitDep
9:15:56 PM: npm ERR! prepareGitDep > keccak@3.0.1 install /opt/buildhome/.npm/_cacache/tmp/git-clone-74f34f89/node_modules/keccak
9:15:56 PM: npm ERR! prepareGitDep > node-gyp-build || exit 0
9:15:56 PM: npm ERR! prepareGitDep
9:15:56 PM: npm ERR! prepareGitDep
9:15:56 PM: npm ERR! prepareGitDep > secp256k1@4.0.2 install /opt/buildhome/.npm/_cacache/tmp/git-clone-74f34f89/node_modules/secp256k1
9:15:56 PM: npm ERR! prepareGitDep > node-gyp-build || exit 0
9:15:56 PM: npm ERR! prepareGitDep
9:15:56 PM: npm ERR! prepareGitDep
9:15:56 PM: npm ERR! prepareGitDep > utf-8-validate@5.0.5 install /opt/buildhome/.npm/_cacache/tmp/git-clone-74f34f89/node_modules/utf-8-validate
9:15:56 PM: npm ERR! prepareGitDep > node-gyp-build
9:15:56 PM: npm ERR! prepareGitDep
9:15:56 PM: npm ERR! prepareGitDep
9:15:56 PM: npm ERR! prepareGitDep > core-js@2.6.12 postinstall /opt/buildhome/.npm/_cacache/tmp/git-clone-74f34f89/node_modules/babel-runtime/node_modules/core-js
9:15:56 PM: npm ERR! prepareGitDep > node -e "try{require('./postinstall')}catch(e){}"
9:15:56 PM: npm ERR! prepareGitDep
9:15:56 PM: npm ERR! prepareGitDep
9:15:56 PM: npm ERR! prepareGitDep > core-js@3.14.0 postinstall /opt/buildhome/.npm/_cacache/tmp/git-clone-74f34f89/node_modules/core-js
9:15:56 PM: npm ERR! prepareGitDep > node -e "try{require('./postinstall')}catch(e){}"
9:15:56 PM: npm ERR! prepareGitDep
9:15:56 PM: npm ERR! prepareGitDep
9:15:56 PM: npm ERR! prepareGitDep > core-js-pure@3.14.0 postinstall /opt/buildhome/.npm/_cacache/tmp/git-clone-74f34f89/node_modules/core-js-pure
9:15:56 PM: npm ERR! prepareGitDep > node -e "try{require('./postinstall')}catch(e){}"
9:15:56 PM: npm ERR! prepareGitDep
9:15:56 PM: npm ERR! prepareGitDep
9:15:56 PM: npm ERR! prepareGitDep > ejs@2.7.4 postinstall /opt/buildhome/.npm/_cacache/tmp/git-clone-74f34f89/node_modules/ejs
9:15:56 PM: npm ERR! prepareGitDep > node ./postinstall.js
9:15:56 PM: npm ERR! prepareGitDep
9:15:56 PM: npm ERR! prepareGitDep
9:15:56 PM: npm ERR! prepareGitDep > @project-serum/swap-ui@0.1.3 prepare /opt/buildhome/.npm/_cacache/tmp/git-clone-74f34f89
9:15:56 PM: npm ERR! prepareGitDep > yarn build
9:15:56 PM: npm ERR! prepareGitDep
9:15:56 PM: npm ERR! prepareGitDep
9:15:56 PM: npm ERR! prepareGitDep 2> npm WARN install Usage of the `--dev` option is deprecated. Use `--only=dev` instead.
9:15:56 PM: npm ERR! prepareGitDep npm WARN deprecated babel-eslint@10.1.0: babel-eslint is now @babel/eslint-parser. This package will no longer receive updates.
9:15:56 PM: npm ERR! prepareGitDep npm WARN deprecated circular-json@0.5.9: CircularJSON is in maintenance only, flatted is its successor.
9:15:56 PM: npm ERR! prepareGitDep npm WARN deprecated chokidar@2.1.8: Chokidar 2 will break on node v14+. Upgrade to chokidar 3 with 15x less dependencies.
9:15:56 PM: npm ERR! prepareGitDep npm WARN deprecated fsevents@1.2.13: fsevents 1 will break on node v14+ and could be using insecure binaries. Upgrade to fsevents 2.
9:15:56 PM: npm ERR! prepareGitDep npm WARN deprecated @hapi/joi@15.1.1: Switch to 'npm install joi'
9:15:56 PM: npm ERR! prepareGitDep npm WARN deprecated rollup-plugin-babel@4.4.0: This package has been deprecated and is no longer maintained. Please use @rollup/plugin-babel.
9:15:56 PM: npm ERR! prepareGitDep npm WARN deprecated urix@0.1.0: Please see https://github.com/lydell/urix#deprecated
9:15:56 PM: npm ERR! prepareGitDep npm WARN deprecated @hapi/hoek@8.5.1: This version has been deprecated and is no longer supported or maintained
9:15:56 PM: npm ERR! prepareGitDep npm WARN deprecated @hapi/address@2.1.4: Moved to 'npm install @sideway/address'
9:15:56 PM: npm ERR! prepareGitDep npm WARN deprecated @hapi/bourne@1.3.2: This version has been deprecated and is no longer supported or maintained
9:15:56 PM: npm ERR! prepareGitDep npm WARN deprecated @hapi/topo@3.1.6: This version has been deprecated and is no longer supported or maintained
9:15:56 PM: npm ERR! prepareGitDep npm WARN deprecated resolve-url@0.2.1: https://github.com/lydell/resolve-url#deprecated
9:15:56 PM: npm ERR! prepareGitDep npm WARN deprecated core-js@2.6.12: core-js@<3.3 is no longer maintained and not recommended for usage due to the number of issues. Because of the V8 engine whims, feature detection in old core-js versions could cause a slowdown up to 100x even if nothing is polyfilled. Please, upgrade your dependencies to the actual version of core-js.
9:15:56 PM: npm ERR! prepareGitDep sh: 1: yarn: not found
9:15:56 PM: npm ERR! prepareGitDep npm ERR! code ELIFECYCLE
9:15:56 PM: npm ERR! prepareGitDep npm ERR! syscall spawn
9:15:56 PM: npm ERR! prepareGitDep npm ERR! file sh
9:15:56 PM: npm ERR! prepareGitDep npm ERR! errno ENOENT
9:15:56 PM: npm ERR! prepareGitDep npm ERR! @project-serum/swap-ui@0.1.3 prepare: `yarn build`
9:15:56 PM: npm ERR! prepareGitDep npm ERR! spawn ENOENT
9:15:56 PM: npm ERR! prepareGitDep npm ERR!
9:15:56 PM: npm ERR! prepareGitDep npm ERR! Failed at the @project-serum/swap-ui@0.1.3 prepare script.
9:15:56 PM: npm ERR! prepareGitDep npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
9:15:56 PM: npm ERR! prepareGitDep
9:15:56 PM: npm ERR! prepareGitDep npm ERR! A complete log of this run can be found in:
9:15:56 PM: npm ERR! prepareGitDep npm ERR!     /opt/buildhome/.npm/_logs/2021-06-13T15_45_56_408Z-debug.log
9:15:56 PM: npm ERR! prepareGitDep
9:16:01 PM: npm ERR! premature close
9:16:03 PM: npm ERR! A complete log of this run can be found in:
9:16:03 PM: npm ERR!     /opt/buildhome/.npm/_logs/2021-06-13T15_46_01_925Z-debug.log
9:16:03 PM: Error during NPM install
9:16:03 PM: Build was terminated: Build script returned non-zero exit code: 1
9:16:03 PM: Creating deploy upload records
9:16:03 PM: Failing build: Failed to build site
9:16:03 PM: Failed during stage 'building site': Build script returned non-zero exit code: 1
9:16:03 PM: Finished processing build request in 1m30.070497011s

Hi there, @secretshardul :wave:

Thanks for reaching out, and welcome to the Netlify Forums :netliconfetti:

It looks like this thread has been a bit quiet since you reached out last week-- are you still encountering issues? Let us know! If you are, I will loop in a member of the Support team.