How to install Gatsby@v2? I followed documentation at https://next.gatsbyjs.org/docs/ which is supposed to be docs for the new version. It says to run npm install --global gatsby-cli
. But this command installs version 1. How do I install 2nd version?
Instead of 3.4. 0 you can use whichever version you want. To verify whether it worked, just type gatsby --version on the command line. Show activity on this post.
Using npm to install Gatsby You'll need to install Gatsby globally to use Gatsby CLI commands such as gatsby new . To do so, use npm install with the --global or -g flag. Once the installation completes, you can run gatsby new my-project to create a new Gatsby project.
Since the last major release was in September 2018, Gatsby v3 includes a couple of breaking changes. If you're curious what's new, head over to the v3. 0 release notes.
If you want to start a new project from scratch, you can do
$ mkdir my-new-app
$ cd my-new-app/
Then install the Gatsby and React libraries with Yarn:
$ yarn init -y
$ yarn add gatsby@next react react-dom
To check if you're using the version 2 of Gatsby, open the package.json
file in your project folder, you should see something like:
"dependencies": {
"gatsby": "^2.0.0-beta.16",
"react": "^16.4.1",
"react-dom": "^16.4.1"
}
To update the Gatsby CLI to version 2, in the terminal do:
$ npm install --global [email protected]
Then check the CLI version by
$ gatsby -v
The Gatsby CLI version is not the Gatsby library version, and gatsby new
may or may not give you the latest version you want, so it is always best to check package.json
to verify the Gatsby version
Gatsby 2.0 is currently tagged as next
so you need to run npm install --global gatsby-cli@next
.
Also, you can check which bin file is used if you run gatsby -v
by running which gatsby
or also for all your found bins in the $PATH by running where gatsby
. Whichever paths these commands return, remove the bin files (e.g. rm /usr/local/bin/gatsby
or something like that) and then run npm install --global gatsby-cli@next
again.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With