netlify / create-react-app-lambda

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Throws error about missing yarn

Tobbe opened this issue · comments

I don't have yarn installed, so I tried using npm instead.

npm i -g netlify-cli # Make sure you have the [Netlify CLI](https://github.com/netlify/cli) installed
git clone https://github.com/netlify/create-react-app-lambda ## clone this repo
cd create-react-app-lambda ## change into this repo
npm install # install all dependencies

All of the above commands runs just fine. But then, when I try to run ntl dev, I get this output

$ ntl dev
◈ Netlify Dev ◈
◈ Starting Netlify Dev with create-react-app
◈ Function builder netlify-lambda detected: Running npm script build:lambda
 »   Warning: ◈ This is a beta feature, please give us feedback on how to
 »   improve at https://github.com/netlify/cli/
'yarn' is not recognized as an internal or external command,
operable program or batch file.
{ Error: spawn yarn ENOENT
    at notFoundError (C:\Users\tobbe\AppData\Roaming\npm\node_modules\netlify-cli\node_modules\cross-spawn\lib\enoent.js:6:26)
    at verifyENOENT (C:\Users\tobbe\AppData\Roaming\npm\node_modules\netlify-cli\node_modules\cross-spawn\lib\enoent.js:40:16)
    at ChildProcess.cp.emit (C:\Users\tobbe\AppData\Roaming\npm\node_modules\netlify-cli\node_modules\cross-spawn\lib\enoent.js:27:25)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:239:12)
  code: 'ENOENT',
  errno: 'ENOENT',
  syscall: 'spawn yarn',
  path: 'yarn',
  spawnargs: [ 'start' ] }
{ Error: spawn yarn ENOENT
    at notFoundError (C:\Users\tobbe\AppData\Roaming\npm\node_modules\netlify-cli\node_modules\cross-spawn\lib\enoent.js:6:26)
    at verifyENOENT (C:\Users\tobbe\AppData\Roaming\npm\node_modules\netlify-cli\node_modules\cross-spawn\lib\enoent.js:40:16)
    at ChildProcess.cp.emit (C:\Users\tobbe\AppData\Roaming\npm\node_modules\netlify-cli\node_modules\cross-spawn\lib\enoent.js:27:25)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:239:12)
  code: 'ENOENT',
  errno: 'ENOENT',
  syscall: 'spawn yarn',
  path: 'yarn',
  spawnargs: [ 'start' ] }

C:\Users\tobbe\AppData\Roaming\npm\node_modules\netlify-cli\node_modules\netlify-redirector\lib\redirects.js:116
      throw ex;
      ^
abort({"code":"ENOENT","errno":"ENOENT","syscall":"spawn yarn","path":"yarn","spawnargs":["start"]}) at Error
    at jsStackTrace (C:\Users\tobbe\AppData\Roaming\npm\node_modules\netlify-cli\node_modules\netlify-redirector\lib\redirects.js:1070:13)
    at stackTrace (C:\Users\tobbe\AppData\Roaming\npm\node_modules\netlify-cli\node_modules\netlify-redirector\lib\redirects.js:1087:12)
    at process.abort (C:\Users\tobbe\AppData\Roaming\npm\node_modules\netlify-cli\node_modules\netlify-redirector\lib\redirects.js:8415:44)
    at process.emit (events.js:182:13)
    at processEmit [as emit] (C:\Users\tobbe\AppData\Roaming\npm\node_modules\netlify-cli\node_modules\signal-exit\index.js:155:32)
    at emitPromiseRejectionWarnings (internal/process/promises.js:105:20)
    at process._tickCallback (internal/process/next_tick.js:69:34)

Removing yarn.lock fixes the issue and makes everything run fine on localhost. Since I'm not using yarn locally, I also updated netlify.toml to use npm instead of yarn for building on netlify's servers.

Took a while to figure out why it wasn't working. (Having not worked with Netlify Dev before it wasn't exactly obvious that your lockfile determines what tools it tries to use 😉)

I guess this issue is semi-related too: netlify/cli#328

Anyway. I suggest removing yarn.lock from the repo and instead be more specific about exactly what package versions to use in package.json. Alternatively you could document that yarn needs to be installed for this to work, and why, and ways to work around it.

PR welcome!