Gatsby: [v2] hello-world starter gives gatsby-link errors

Created on 19 Aug 2018  Â·  11Comments  Â·  Source: gatsbyjs/gatsby

Was testing out the new v2 starters and ran
gatsby new hello-world https://github.com/gatsby js/gatsby-starter-hello-world#v2

The command is in https://next.gatsbyjs.org/docs/gatsby-starters/

When I run gatsby develop I get:

These dependencies were not found:

* history in ./node_modules/gatsby-link/index.js
* react-router-dom in ./node_modules/gatsby-link/index.js

To install them, you can run: npm install --save history react-router-dom
✖ 「wdm」: 
ERROR in ./node_modules/gatsby-link/index.js
Module not found: Error: Can't resolve 'history' in '/Users/mgmcewen/Sites/hello-world/node_modules/gatsby-link'
 @ ./node_modules/gatsby-link/index.js 42:15-33
 @ ./.cache/gatsby-browser-entry.js
 @ ./.cache/dev-404-page.js
 @ ./.cache/sync-requires.js
 @ ./.cache/app.js
 @ multi ./node_modules/react-hot-loader/patch.js (webpack)-hot-middleware/client.js?path=http://localhost:8000/__webpack_hmr&reload=true&overlay=false ./.cache/app

ERROR in ./node_modules/gatsby-link/index.js
Module not found: Error: Can't resolve 'react-router-dom' in '/Users/mgmcewen/Sites/hello-world/node_modules/gatsby-link'
 @ ./node_modules/gatsby-link/index.js 36:22-49
 @ ./.cache/gatsby-browser-entry.js
 @ ./.cache/dev-404-page.js
 @ ./.cache/sync-requires.js
 @ ./.cache/app.js
 @ multi ./node_modules/react-hot-loader/patch.js (webpack)-hot-middleware/client.js?pa

I tried deleting .cache and still got the error. The other v2 starter I tried gatsby-starter-default works fine.

needs more info

Most helpful comment

I saw the same issue and it was due the package.json having the v1 version.
I changed the below and it works fine.

-    "gatsby-link": "^1.6.45",
+    "gatsby-link": "next",

All 11 comments

Couldn't reproduce.

According to the error message, the issue is with missing packages. So probably npm/yarn didn't run correctly. Or gatsby-cli is outdated.

Removing node_modules with lock file and reinstalling the dependencies usually helps me in similar situations

Also, it's strange that react-router-dom is missing, since it's no longer used in v2.

@melissamcewen what versions of npm/gatsby are you using? I just ran the following and it successfully installed the project:

Trying to repro:

  • npm install --global gatsby-cli@next
  • gatsby new hello-world https://github.com/gatsbyjs/gatsby-starter-hello-world#v2
  • gatsby develop

This starts the development server as I would expect without any missing package errors.

My local setup:

gatsby -v
2.0.0-beta.14

npm -v
5.6.0

node -v
v8.11.4

Couldn't reproduce either. Try removing the node_modules directory and the package-lock.json file.
And then reinstall using npm install or yarn install and see if you still get the error.

If you do, then it'd be helpful if you can show us the version of gatsby, node & npm.

Seems related to #6834.

I was on NPM 5 😳

So if you get this error try upgrading NPM or using Yarn

I had the same issue. I can confirm it's NPM 5 issue. I updated to 6.4.0 and the dev server compiled first time.

I saw the same issue and it was due the package.json having the v1 version.
I changed the below and it works fine.

-    "gatsby-link": "^1.6.45",
+    "gatsby-link": "next",

I also had the issue but it seemed to be due having the wrong gatsby-cli version. I uninstalled and reinstalled the cli with npm install --global gatsby-cli@next and I'm back in business.

See if you mixed yarn with npm, or vice versa

@Jaikant gatsby-link is not used anymore.
https://www.gatsbyjs.org/docs/migrating-from-v1-to-v2/#import-link-from-gatsby
In which cases do you import gatsby-link?

@dantehemerson you are right. gatsby-link should also be removed from the package.json and the node_modules deleted and reinstalled.

Was this page helpful?
0 / 5 - 0 ratings