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

Gatsby breaks with yarn 1.x #2244

Closed
ahmedelgabri opened this issue Sep 26, 2017 · 13 comments
Closed

Gatsby breaks with yarn 1.x #2244

ahmedelgabri opened this issue Sep 26, 2017 · 13 comments
Labels
type: documentation An issue or pull request for improving or updating Gatsby's documentation

Comments

@ahmedelgabri
Copy link
Contributor

ahmedelgabri commented Sep 26, 2017

After updating yarn, I can't build anymore. yarn 0.27.5 works fine but not 1.x. Here is the repo & this is the error I'm getting:

λ yarn run build
yarn run v1.1.0
$ gatsby build
success delete html files from previous builds — 0.042 s
success open and validate gatsby-config.js — 0.004 s
success copy gatsby files — 0.019 s
success source and transform nodes — 0.131 s
success building schema — 0.219 s
success createLayouts — 0.007 s
success createPages — 0.051 s
success createPagesStatefully — 0.008 s
success extract queries from components — 0.079 s
success run graphql queries — 0.733 s
success write out page data — 0.003 s
success update schema — 0.092 s

info bootstrap finished - 2.567 s

success Building CSS — 0.523 s
success Building production JavaScript bundles — 0.119 s

error Building static HTML for pages failed

See our docs page on debugging HTML builds for help https://goo.gl/yL9lND


  Error: Error: Cannot resolve module 'babel' in /Users/ahmed/Sites/dev/gabrime
  resolve module babel in /Users/ahmed/Sites/dev/gabrime
    looking for modules in /Users/ahmed/Sites/dev/gabrime/node_modules
      module variation babel-webpack-node-loader
        /Users/ahmed/Sites/dev/gabrime/node_modules/babel-webpack-node-loader doesn't exist (module as directory)
        resolve 'file' babel-webpack-node-loader in /Users/ahmed/Sites/dev/gabrime/node_modules
          resolve file
            /Users/ahmed/Sites/dev/gabrime/node_modules/babel-webpack-node-loader doesn't exist
            /Users/ahmed/Sites/dev/gabrime/node_modules/babel-webpack-node-loader.webpack-node-loader.js doesn't exist
            /Users/ahmed/Sites/dev/gabrime/node_modules/babel-webpack-node-loader.loader.js doesn't exist
            /Users/ahmed/Sites/dev/gabrime/node_modules/babel-webpack-node-loader.js doesn't exist
      module variation babel-node-loader
        /Users/ahmed/Sites/dev/gabrime/node_modules/babel-node-loader doesn't exist (module as directory)
        resolve 'file' babel-node-loader in /Users/ahmed/Sites/dev/gabrime/node_modules
          resolve file
            /Users/ahmed/Sites/dev/gabrime/node_modules/babel-node-loader doesn't exist
            /Users/ahmed/Sites/dev/gabrime/node_modules/babel-node-loader.webpack-node-loader.js doesn't exist
            /Users/ahmed/Sites/dev/gabrime/node_modules/babel-node-loader.loader.js doesn't exist
            /Users/ahmed/Sites/dev/gabrime/node_modules/babel-node-loader.js doesn't exist
      module variation babel-loader
        /Users/ahmed/Sites/dev/gabrime/node_modules/babel-loader doesn't exist (module as directory)
        resolve 'file' babel-loader in /Users/ahmed/Sites/dev/gabrime/node_modules
          resolve file
            /Users/ahmed/Sites/dev/gabrime/node_modules/babel-loader doesn't exist
            /Users/ahmed/Sites/dev/gabrime/node_modules/babel-loader.webpack-node-loader.js doesn't exist
            /Users/ahmed/Sites/dev/gabrime/node_modules/babel-loader.loader.js doesn't exist
            /Users/ahmed/Sites/dev/gabrime/node_modules/babel-loader.js doesn't exist
      module variation babel
        /Users/ahmed/Sites/dev/gabrime/node_modules/babel doesn't exist (module as directory)
        resolve 'file' babel in /Users/ahmed/Sites/dev/gabrime/node_modules
          resolve file
            /Users/ahmed/Sites/dev/gabrime/node_modules/babel doesn't exist
            /Users/ahmed/Sites/dev/gabrime/node_modules/babel.webpack-node-loader.js doesn't exist
            /Users/ahmed/Sites/dev/gabrime/node_modules/babel.loader.js doesn't exist
            /Users/ahmed/Sites/dev/gabrime/node_modules/babel.js doesn't exist
    looking for modules in /Users/ahmed/Sites/dev/gabrime/node_modules
      module variation babel-webpack-node-loader
        resolve 'file' babel-webpack-node-loader in /Users/ahmed/Sites/dev/gabrime/node_modules
          resolve file
            /Users/ahmed/Sites/dev/gabrime/node_modules/babel-webpack-node-loader doesn't exist
            /Users/ahmed/Sites/dev/gabrime/node_modules/babel-webpack-node-loader.webpack-node-loader.js doesn't exist
            /Users/ahmed/Sites/dev/gabrime/node_modules/babel-webpack-node-loader.loader.js doesn't exist
            /Users/ahmed/Sites/dev/gabrime/node_modules/babel-webpack-node-loader.js doesn't exist
        /Users/ahmed/Sites/dev/gabrime/node_modules/babel-webpack-node-loader doesn't exist (module as directory)
      module variation babel-node-loader
        resolve 'file' babel-node-loader in /Users/ahmed/Sites/dev/gabrime/node_modules
          resolve file
            /Users/ahmed/Sites/dev/gabrime/node_modules/babel-node-loader doesn't exist
            /Users/ahmed/Sites/dev/gabrime/node_modules/babel-node-loader.webpack-node-loader.js doesn't exist
            /Users/ahmed/Sites/dev/gabrime/node_modules/babel-node-loader.loader.js doesn't exist
            /Users/ahmed/Sites/dev/gabrime/node_modules/babel-node-loader.js doesn't exist
        /Users/ahmed/Sites/dev/gabrime/node_modules/babel-node-loader doesn't exist (module as directory)
      module variation babel-loader
        resolve 'file' babel-loader in /Users/ahmed/Sites/dev/gabrime/node_modules
          resolve file
            /Users/ahmed/Sites/dev/gabrime/node_modules/babel-loader doesn't exist
            /Users/ahmed/Sites/dev/gabrime/node_modules/babel-loader.webpack-node-loader.js doesn't exist
            /Users/ahmed/Sites/dev/gabrime/node_modules/babel-loader.loader.js doesn't exist
            /Users/ahmed/Sites/dev/gabrime/node_modules/babel-loader.js doesn't exist
        /Users/ahmed/Sites/dev/gabrime/node_modules/babel-loader doesn't exist (module as directory)
      module variation babel
        resolve 'file' babel in /Users/ahmed/Sites/dev/gabrime/node_modules
          resolve file
            /Users/ahmed/Sites/dev/gabrime/node_modules/babel doesn't exist
            /Users/ahmed/Sites/dev/gabrime/node_modules/babel.webpack-node-loader.js doesn't exist
            /Users/ahmed/Sites/dev/gabrime/node_modules/babel.loader.js doesn't exist
            /Users/ahmed/Sites/dev/gabrime/node_modules/babel.js doesn't exist
        /Users/ahmed/Sites/dev/gabrime/node_modules/babel doesn't exist (module as directory)

error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
[1]    36348 exit 1     yarn run build

Deleting yarn.lock & node_modules & starting from scratch yields another error.

λ yarn build
yarn run v1.1.0
$ gatsby build
error A local install of Gatsby exists but failed to load.


  Error: Cannot find module 'relay-compiler/lib/RelayCompilerContext'

  - module.js:11 require
    internal/module.js:11:18

  - query-compiler.js:37 Object.<anonymous>
    [gabrime]/[gatsby]/dist/internal-plugins/query-runner/query-compiler.js:37:29

  - module.js:11 require
    internal/module.js:11:18

  - query-watcher.js:22 Object.<anonymous>
    [gabrime]/[gatsby]/dist/internal-plugins/query-runner/query-watcher.js:22:21


   Done in 1.67s.
@paulathevalley
Copy link
Contributor

I just ran into the same error with yarn v0.27.5 😕 after I ran yarn upgrade.

yarn run v0.27.5
$ gatsby develop
error A local install of Gatsby exists but failed to load.


  Error: Cannot find module 'relay-compiler/lib/RelayCompilerContext'
  
  - module.js:11 require
    internal/module.js:11:18
  
  - query-compiler.js:37 Object.<anonymous>
    [victory-docs]/[gatsby]/dist/internal-plugins/query-runner/query-compiler.js:37:29
  
  - module.js:11 require
    internal/module.js:11:18
  
  - query-watcher.js:22 Object.<anonymous>
    [victory-docs]/[gatsby]/dist/internal-plugins/query-runner/query-watcher.js:22:21
  

Done in 2.12s.

I ended up restoring my older yarn.lock and it resolved the error. I thought it may have been solved by downgrading to relay-compiler@1.1.0, but the yarn.lock in the repo you linked looks like it’s on that same version, too. 😞

@swim
Copy link
Contributor

swim commented Sep 29, 2017

Looks like it's related to yarnpkg/yarn#4478?

@ahmedelgabri
Copy link
Contributor Author

@swim it said that it was fixed in 1.1.0 which is the version I'm using & still having issues.

@KyleAMathews
Copy link
Contributor

The relay-compiler error was fixed in core recently as their 1.3.x -> 1.4.x update broke us. The version is pinned now so if you upgrade to the latest Gatsby things should work.

FWIW, I've been using Yarn 1.x on my mac for the last few weeks without trouble.

@ahmedelgabri
Copy link
Contributor Author

Updating to the latest version didn't fix the problem for me. I delete the node_modules & yarn.lock to generate a new lock file & still. Same error

@KyleAMathews
Copy link
Contributor

This is any site? E.g. all the official starters fail?

@ahmedelgabri
Copy link
Contributor Author

I linked to the repo I’m referreing to in my first post already. I didn’t try any starters.

@m-allanson
Copy link
Contributor

I got the same error when trying to build Gatsby on the repo mentioned in the first comment using yarn 1.1.0. Here's the output from my terminal: https://gist.github.com/m-allanson/59c55ffb705246e4a69c2c7d9366031b

I didn't get any errors when I tried yarn install followed by yarn build on the gatsbygram and using-redux examples. (I'm new to Gatsby but have encountered a couple of similar errors to those mentioned above.)

@ahmedelgabri
Copy link
Contributor Author

ahmedelgabri commented Sep 30, 2017

Ok, found the problem(s) & fixed it.

  • gatsby-plugin-emotion now has emotion as a peerDependency, previously it was a direct dependency & was released as a patch so when I updated the plugin things stopped working.
  • I had webpack installed as a direct devDependecy I think I forgot to remove it when I was experimenting with something. I think this was also the reason for the babel errors.
  • Then I had a couple of missing ; in CSS when I used emotion's css prop.

My only request here is better error messages maybe & when a breaking change like this happen in one of the plugins maybe it should be released as major. The rest was some mistakes from my side.

@sebastienfi sebastienfi added API/Plugins type: documentation An issue or pull request for improving or updating Gatsby's documentation labels Oct 1, 2017
@sebastienfi
Copy link
Contributor

@ahmedelgabri I see the need for better error messages. Could you please detail what you would have needed to see and maybe PR on that ?

@ahmedelgabri
Copy link
Contributor Author

@sebastienfi something more related to the issue, not sure what caused the babel error message. Maybe the installed webpack? if yes then maybe something related to this.

For gatsby-plugin-emotion I think the solution is in a proper versioning, the change was definitely not a patch.

@KyleAMathews
Copy link
Contributor

the change was definitely not a patch.

Yeah, this was my fault. The recent PR with the changes should have been a v2.

@KyleAMathews
Copy link
Contributor

Closing this issue as it's fairly old and we have far too many open issues! If you have additional problems in this area, please open a new issue!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: documentation An issue or pull request for improving or updating Gatsby's documentation
Projects
None yet
Development

No branches or pull requests

6 participants