Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to install Gatsby@2(beta)

Tags:

gatsby

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?

like image 723
Varvara Stepanova Avatar asked Jul 03 '18 09:07

Varvara Stepanova


People also ask

How do I install a specific version of Gatsby?

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.

How do I install Gatsby packages?

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.

What's the latest version of Gatsby?

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.


2 Answers

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

like image 156
zenoh Avatar answered Oct 22 '22 17:10

zenoh


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.

like image 3
Maxim Zubarev Avatar answered Oct 22 '22 17:10

Maxim Zubarev