Xo: `xo --init` crashes out if yarn.lock is present but yarn isn't available

Created on 18 May 2018  路  2Comments  路  Source: xojs/xo

$ xo --init
Error: spawn yarn ENOENT
    at Process.ChildProcess._handle.onexit (internal/child_process.js:227:19)
    at onErrorNT (internal/child_process.js:404:16)
    at process._tickCallback (internal/process/next_tick.js:63:19)
    at Function.Module.runMain (internal/modules/cjs/loader.js:721:11)
    at startup (internal/bootstrap/node.js:228:19)
    at bootstrapNodeJSCore (internal/bootstrap/node.js:576:3)

It took me a while to realise that xo had detected the use of yarn (probably due to yarn.lock), but the yarn command (or module) wasn't currently available. This situation should at least result in a human-readable error if there isn't a better way to handle it.

enhancement help wanted

All 2 comments

Yes, we should show a user-friendly error, like:

This project uses Yarn but you don't seem to have Yarn installed.
Run `npm install --global yarn` to install it.

@sindresorhus I just send a PR to the xo-init repo for send this message.
https://github.com/xojs/xo-init/pull/17

Was this page helpful?
0 / 5 - 0 ratings

Related issues

iwata picture iwata  路  5Comments

niftylettuce picture niftylettuce  路  6Comments

sindresorhus picture sindresorhus  路  5Comments

pizzafox picture pizzafox  路  5Comments

pizzafox picture pizzafox  路  7Comments