Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[v2] hello-world starter gives gatsby-link errors #7457

Closed
melissamcewen opened this issue Aug 19, 2018 · 11 comments
Closed

[v2] hello-world starter gives gatsby-link errors #7457

melissamcewen opened this issue Aug 19, 2018 · 11 comments
Labels
status: needs more info Needs triaging and reproducible examples or more information to be resolved

Comments

@melissamcewen
Copy link
Contributor

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.

@azdanov
Copy link
Contributor

azdanov commented Aug 20, 2018

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.

@kylecesmat
Copy link
Contributor

kylecesmat commented Aug 20, 2018

@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

@iamtraction
Copy link
Contributor

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.

@iamtraction iamtraction added the status: needs reproduction This issue needs a simplified reproduction of the bug for further troubleshooting. label Aug 20, 2018
@Chuloo Chuloo added status: needs more info Needs triaging and reproducible examples or more information to be resolved and removed status: needs reproduction This issue needs a simplified reproduction of the bug for further troubleshooting. labels Aug 20, 2018
@Chuloo
Copy link
Contributor

Chuloo commented Aug 20, 2018

Seems related to #6834.

@melissamcewen
Copy link
Contributor Author

I was on NPM 5 😳

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

@m1r9h71
Copy link

m1r9h71 commented Aug 23, 2018

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.

@Jaikant
Copy link
Contributor

Jaikant commented Aug 29, 2018

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",

@jonesjj
Copy link

jonesjj commented Sep 15, 2018

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.

@gondar00
Copy link

gondar00 commented Sep 18, 2018

See if you mixed yarn with npm, or vice versa

@dantehemerson
Copy link
Contributor

@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?

@Jaikant
Copy link
Contributor

Jaikant commented Nov 14, 2018

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: needs more info Needs triaging and reproducible examples or more information to be resolved
Projects
None yet
Development

No branches or pull requests

10 participants