(gatsby-cli): `gatsby new` => Command failed with ENOENT: yarnpkg
See original GitHub issueSummary
While following the tutorial I got an error because yarn is necessary but isn’t listed as needing to be installed
$ nvm current
v14.13.0
$ node --version
v14.13.0
$ npm --version
6.14.8
$ npm install -g gatsby-cli
Success!
Welcome to the Gatsby CLI! Please visit https://www.gatsbyjs.org/docs/gatsby-cli/ for more information.
+ gatsby-cli@2.12.105
$ gatsby --version
Gatsby CLI version: 2.12.105
$ gatsby new hello-world https://github.com/gatsbyjs/gatsby-starter-hello-world
info Creating new site from git: https://github.com/gatsbyjs/gatsby-starter-hello-world.git
Cloning into 'hello-world'...
remote: Enumerating objects: 16, done.
remote: Counting objects: 100% (16/16), done.
remote: Compressing objects: 100% (11/11), done.
remote: Total 16 (delta 0), reused 9 (delta 0), pack-reused 0
Unpacking objects: 100% (16/16), 389.79 KiB | 1.21 MiB/s, done.
success Created starter directory layout
info Installing packages...
ERROR
Command failed with ENOENT: yarnpkg
spawn yarnpkg ENOENT
Error: Command failed with ENOENT: yarnpkg
spawn yarnpkg ENOENT
- child_process.js:268 Process.ChildProcess._handle.onexit
internal/child_process.js:268:19
- child_process.js:464 onErrorNT
internal/child_process.js:464:16
- task_queues.js:80 processTicksAndRejections
internal/process/task_queues.js:80:21
Motivation
This doesn’t help being reassured at using gatsby if the basically first step of getting to know it ends up in errors …
Steps to resolve this issue
After installing yarn with npm install -i yarn
problem is solved
Draft the doc
I don’t know where the information should be placed but perhaps modifying the Set default Node.js version chapter to include the yarn installation could do it. Let me know if that’s OK and I’ll make a PR
Regards, Nicolas
Issue Analytics
- State:
- Created 3 years ago
- Comments:8 (8 by maintainers)
Top Results From Across the Web
Command to create a new project using gatsby not working
Since Git was not configured for cmd, the command failed. Ran the command at a Git Bash (MinTTY) prompt and the command worked....
Read more >Why Did Dependency Installation Fail? - Gatsby Cloud
Re-install dependencies; Commit the new lock file; Push the updated lock file to your remote repository. References. [1] https://classic.yarnpkg ...
Read more >'gatsby' is not recognized as an internal or external command ...
I created a new gatsby project after installing Node, NPM, and Gatsby CLI. The project was working fine. I tried to deploy on...
Read more >Command failed with exit code 1: npm run build - Netlify fix 2020
Udemy Courses:- 9 React Projects on Udemy - https://bit.ly/2D83M8c- 9 React Projects on Gumroad ...
Read more >gatsby-cli | Yarn - Package Manager
Install it globally with npm install -g gatsby-cli , where you execute commands with the syntax gatsby new , or ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Ok after digging in cli sources, it seems I kept a ~/.config/gatsby/config.json file from a past installation / usage
And gatsby-cli do trust that config file even if packageManager isn’t available anymore. After removing it, gatsby-cli is working as expected again !
Perhaps hardening cli by testing if packageManager bin really exists before using it and log a warning otherwise could be a good idea. What do you think ?
Regards, Nicolas
Thanks @laurieontech , I did test your fix, it doesn’t work. I think I found the bug and the fix just let me 5 sec to test and push a PR ^^