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

Getting gatsby setup locally #518

Closed
brianstone opened this issue Oct 27, 2016 · 11 comments
Closed

Getting gatsby setup locally #518

brianstone opened this issue Oct 27, 2016 · 11 comments

Comments

@brianstone
Copy link
Contributor

"gatsby": "^0.12.18"
node: v6.3.1
macOS Sierra

I am moving this to a new issue from a discovery I made on #483 in regards to setting up gatsby locally.

After some troubleshooting, I believe the problem is happening with babel. I have followed the steps in CONTRIBUTING.md, but when I run gatsby new project-name I get the following output:

/Users/brianstone/code/gatsby/node_modules/babel-core/lib/transformation/file/index.js:600
      throw err;
      ^

Error: /Users/brianstone/code/gatsby/dist/bin/cli.js: Cannot find module
  at PluginPass.Program (/Users/brianstone/code/gatsby/node_modules/babel-plugin-lodash/lib/index.js:97:15)
  at newFn (/Users/brianstone/code/gatsby/node_modules/babel-traverse/lib/visitors.js:276:21)
  at NodePath._call (/Users/brianstone/code/gatsby/node_modules/babel-traverse/lib/path/context.js:76:18)
  at NodePath.call (/Users/brianstone/code/gatsby/node_modules/babel-traverse/lib/path/context.js:48:17)
  at NodePath.visit (/Users/brianstone/code/gatsby/node_modules/babel-traverse/lib/path/context.js:105:12)
  at TraversalContext.visitQueue (/Users/brianstone/code/gatsby/node_modules/babel-traverse/lib/context.js:150:16)
  at TraversalContext.visitSingle (/Users/brianstone/code/gatsby/node_modules/babel-traverse/lib/context.js:108:19)
  at TraversalContext.visit (/Users/brianstone/code/gatsby/node_modules/babel-traverse/lib/context.js:192:19)
  at Function.traverse.node (/Users/brianstone/code/gatsby/node_modules/babel-traverse/lib/index.js:114:17)
  at traverse (/Users/brianstone/code/gatsby/node_modules/babel-traverse/lib/index.js:79:12)
  at File.transform (/Users/brianstone/code/gatsby/node_modules/babel-core/lib/transformation/file/index.js:558:35)
  at /Users/brianstone/code/gatsby/node_modules/babel-core/lib/transformation/pipeline.js:50:19
  at File.wrap (/Users/brianstone/code/gatsby/node_modules/babel-core/lib/transformation/file/index.js:574:16)
  at Pipeline.transform (/Users/brianstone/code/gatsby/node_modules/babel-core/lib/transformation/pipeline.js:47:17)
  at Object.transformFileSync (/Users/brianstone/code/gatsby/node_modules/babel-core/lib/api/node.js:138:10)
  at compile (/Users/brianstone/code/gatsby/node_modules/babel-register/lib/node.js:118:20)
  at loader (/Users/brianstone/code/gatsby/node_modules/babel-register/lib/node.js:144:14)
  at Object.require.extensions.(anonymous function) [as .js] (/Users/brianstone/code/gatsby/node_modules/babel-register/lib/node.js:154:7)
  at Module.load (/Users/brianstone/code/gatsby/node_modules/coffee-script/lib/coffee-script/register.js:45:36)
  at tryModuleLoad (module.js:417:12)
  at Function.Module._load (module.js:409:3)
  at Module.require (module.js:468:17)
  at require (internal/module.js:20:19)
  at loadGatsby (/Users/brianstone/code/gatsby/bin/gatsby.js:30:3)
  at /Users/brianstone/code/gatsby/bin/gatsby.js:44:5
  at FSReqWrap.oncomplete (fs.js:123:15)

I feel like this has something to do with babel not transpiling properly here:

 transform(): BabelFileResult {
    // In the "pass per preset" mode, we have grouped passes.
    // Otherwise, there is only one plain pluginPasses array.
    for (let i = 0; i < this.pluginPasses.length; i++) {
      const pluginPasses = this.pluginPasses[i];
      this.call("pre", pluginPasses);
      this.log.debug("Start transform traverse");

      // merge all plugin visitors into a single visitor
      let visitor = traverse.visitors.merge(this.pluginVisitors[i], pluginPasses, this.opts.wrapPluginVisitorMethod);
      traverse(this.ast, visitor, this.scope);

      this.log.debug("End transform traverse");
      this.call("post", pluginPasses);
    }

Any ideas as to why this might be happening?

@KyleAMathews
Copy link
Contributor

From the stack trace it looks like it might have something to do with babel-plugin-lodash not being found? Is that in your .babelrc?

@oliverbenns
Copy link
Contributor

I am also experiencing similar issues, but when installing globally. Node 6.3.0, OSX Sierra.

Error: Cannot find module 
'/Users/oliver/.nvm/versions/node/v6.3.0/lib/node_modules/gatsby/dist/bin/cli.js'
  at Function.Module._resolveFilename (module.js:440:15)
  at Function.Module._load (module.js:388:25)
  at Module.require (module.js:468:17)
  at require (internal/module.js:20:19)
  at loadGatsby (/Users/oliver/.nvm/versions/node/v6.3.0/lib/node_modules/gatsby/bin/gatsby.js:30:3)
  at /Users/oliver/.nvm/versions/node/v6.3.0/lib/node_modules/gatsby/bin/gatsby.js:44:5
  at FSReqWrap.oncomplete (fs.js:123:15)

@KyleAMathews
Copy link
Contributor

@oliverbenns could you try uninstalling and installing again? npm uninstall -g gatsby; npm install -g gatsby

@oliverbenns
Copy link
Contributor

oliverbenns commented Oct 27, 2016

Yeah I have done, and restarted. I was convinced this was the culprit, alas, it is not the case.

@KyleAMathews
Copy link
Contributor

Hmmm... I just installed gatsby global from scratch and created a new site and it worked as expected...

Have you tried just cloning a starter directly and running npm install; npm run dev?

@oliverbenns
Copy link
Contributor

Ok I managed to fix it. I deleted my git clone of Gatsby (which was located ~/Sites/gatsby) and ran the global install again.

But when I ran the global install beforehand I did it above the directory to ensure it didn't traverse to ~/Sites/gatsby. So it's weird that that has somehow fixed it..

@savolai
Copy link

savolai commented Jan 18, 2017

Not sure if this should be an issue of its own. I had issues getting gatsby working on windows. On the windows 10 ubuntu bash couldn't get it working at all.

When I installed node with the official installer from their website, I still needed to do

npm install --save react-motion react-responsive-grid underscore.string chroma-js color-pairs-picker typography-plugin-code

after "npm install -g gatsby" to get my version of gatsby-starter-documentation to actually served in gatsby develop on localhost.

@KyleAMathews
Copy link
Contributor

KyleAMathews commented Jan 18, 2017 via email

@savolai
Copy link

savolai commented Jan 18, 2017

Oh - no. Node's overall logic still eludes me, as I don't use it regularly. I assumed the instructions at https://github.com/gatsbyjs/gatsby#getting-started suffice.

Since the documentation site starter was already there and cloned via git, I didn't assume I needed to do that again. Although I can now see that those are not included in the git repo and so it makes sense to fetch the deps separately, well.

It also makes a lot of sense for newbs to assume the ordinary logic of having an application and data files of that application being self-contained.

Perhaps an UX point to consider in the long run? For example, have "gatsby develop" recognize when deps are not there and suggest user to run 'npm install'.

@KyleAMathews
Copy link
Contributor

@savolai did you create the site with gatsby new? That should have installed the npm packages for you... if they didn't that's a bug of some sort.

We do check if Gatsby itself is installed. Beyond that, it's a bit hard to know for sure if a dependency is "needed" or not. Perhaps there are some additional low-hanging dependency checks we could add.

@savolai
Copy link

savolai commented Jan 24, 2017

Oh right, my bad. Didn't realize I can use gatsby new for starters, as well.

@jbolda jbolda added the v0 label Jun 3, 2017
@jbolda jbolda closed this as completed Jun 3, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants