Skip to content
This repository has been archived by the owner on Jul 5, 2022. It is now read-only.

yarn is required to build the bindings #5

Open
anoadragon453 opened this issue May 4, 2022 · 0 comments
Open

yarn is required to build the bindings #5

anoadragon453 opened this issue May 4, 2022 · 0 comments

Comments

@anoadragon453
Copy link
Member

On attempting to install matrix-bot-sdk (a project which uses this library), the check-exists.js script runs, which tries to build these bindings.

if (process.env.NODE_ENV === "production") {
code = require('shelljs').exec('yarn build:release').code;
} else {
code = require('shelljs').exec('yarn build:debug').code;
}

This requires the user to have yarn installed, which isn't always the case:

$ npm i -s matrix-bot-sdk@beta --verbose
npm verb cli [
npm verb cli   '/usr/local/bin/node',
npm verb cli   '/usr/local/bin/npm',
npm verb cli   'i',
npm verb cli   '-s',
npm verb cli   'matrix-bot-sdk@beta',
npm verb cli   '--verbose'
npm verb cli ]
npm info using npm@8.5.0
npm info using node@v16.14.2
... REMOVED FOR BREVITY
npm timing build:link:node_modules/matrix-bot-sdk/node_modules/mkdirp Completed in 1ms
npm timing build:link:node_modules/postcss/node_modules/nanoid Completed in 2ms
npm timing build:link Completed in 2ms
npm info run @turt2live/matrix-sdk-crypto-nodejs@0.1.0-beta.10 postinstall node_modules/@turt2live/matrix-sdk-crypto-nodejs node check-exists.js
npm info run @turt2live/matrix-sdk-crypto-nodejs@0.1.0-beta.10 postinstall { code: 127, signal: null }
npm timing reify:rollback:createSparse Completed in 67ms
npm timing reify:rollback:retireShallow Completed in 0ms
npm timing command:i Completed in 3282ms
npm verb stack Error: command failed
npm verb stack     at ChildProcess.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/@npmcli/promise-spawn/index.js:64:27)
npm verb stack     at ChildProcess.emit (node:events:526:28)
npm verb stack     at maybeClose (node:internal/child_process:1092:16)
npm verb stack     at Process.ChildProcess._handle.onexit (node:internal/child_process:302:5)
npm verb pkgid @turt2live/matrix-sdk-crypto-nodejs@0.1.0-beta.10
npm verb cwd /Users/user/projects/my-project
npm verb Darwin 21.4.0
npm verb argv "/usr/local/bin/node" "/usr/local/bin/npm" "i" "-s" "matrix-bot-sdk@beta" "--verbose"
npm verb node v16.14.2
npm verb npm  v8.5.0
npm ERR! code 127
npm ERR! path /Users/user/projects/my-project/node_modules/@turt2live/matrix-sdk-crypto-nodejs
npm ERR! command failed
npm ERR! command sh -c node check-exists.js
**npm ERR! /bin/sh: yarn: command not found**
npm verb exit 127
npm timing npm Completed in 3406ms

npm verb code 127

Is it necessary to use yarn for this, or can we use npm here? (It seems that at the end of the day this is all just wrapping calls to napi):

"scripts": {
"rust:targets": "rustup target add x86_64-pc-windows-msvc i686-pc-windows-msvc x86_64-unknown-linux-gnu i686-unknown-linux-gnu x86_64-apple-darwin",
"build:win": "yarn build:win:x64 && yarn build:win:ia32",
"build:win:x64": "napi build --js ./lib/napi-module.js --dts napi-module.d.ts --release --platform --target x86_64-pc-windows-msvc ./lib",
"build:win:ia32": "napi build --js ./lib/napi-module.js --dts napi-module.d.ts --release --platform --target i686-pc-windows-msvc ./lib",
"build:linux": "yarn build:linux:x64 && yarn build:linux:ia32",
"build:linux:x64": "napi build --js ./lib/napi-module.js --dts napi-module.d.ts --release --platform --target x86_64-unknown-linux-gnu ./lib",
"build:linux:ia32": "napi build --js ./lib/napi-module.js --dts napi-module.d.ts --release --platform --target i686-unknown-linux-gnu ./lib",
"build:darwin": "yarn build:darwin:x64",
"build:darwin:x64": "napi build --js ./lib/napi-module.js --dts napi-module.d.ts --release --platform --target x86_64-apple-darwin ./lib",
"build:types": "napi build --js ./lib/napi-module.js --dts napi-module.d.ts --platform ./lib",
"build:release": "yarn build:types && napi build --release ./lib",
"build:debug": "yarn build:types && napi build --js ./lib/napi-module.js --dts napi-module.d.ts ./lib",
"build:ts": "tsc",
"build:test": "napi build",
"prepublishOnly": "yarn build:ts && ./prepare-release.sh",
"postinstall": "node check-exists.js"
},

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant