Giter Site home page Giter Site logo

Comments (9)

KyleAMathews avatar KyleAMathews commented on April 28, 2024

I think I removed it accidentally earlier... though it was working on my
machine. I'll be home in a bit and will fix and release. Thanks for filing
an issue!

In the meantime downgrade to 0.5.0 which is almost identical.
On Sat, Oct 3, 2015 at 6:01 PM Luandro [email protected] wrote:

Just installed a fresh copy of gatsby, and created a blog. When I try to
run gatsby serve I get this error:

/usr/local/lib/node_modules/gatsby/lib/utils/serve.js:2
import Hapi from 'hapi';
^^^^^^
SyntaxError: Unexpected reserved word

Seems like babel isn't running for some reason. Any clues?


Reply to this email directly or view it on GitHub
#54.

from gatsby.

luandro avatar luandro commented on April 28, 2024

👍

from gatsby.

KyleAMathews avatar KyleAMathews commented on April 28, 2024

Hmmm... so babel-node doesn't work with globally installed packages...
babel/babel#1889

It's suggested that you pre-compile your code... not fun...

from gatsby.

KyleAMathews avatar KyleAMathews commented on April 28, 2024

Ok, I think things should work now with 0.6.1.

@gesposito looks like we're either going to have to go vanilla ES5 or pre-compile code.

from gatsby.

gesposito avatar gesposito commented on April 28, 2024

What are the steps to reproduce this?
I have 0.6.0 -g installed and I tested serve against all the starter sites and they worked.

from gatsby.

KyleAMathews avatar KyleAMathews commented on April 28, 2024

Basically that :) Did you run npm link though against your local clone of Gatsby? It does work in that scenario which is why I didn't detect it until @luandro reported the bug.

from gatsby.

gesposito avatar gesposito commented on April 28, 2024

Yeah, I still had the npm linked version on.
I'll take a look at it if I can.

from gatsby.

gesposito avatar gesposito commented on April 28, 2024

So, I dug a bit, and found that babel actually might ignore gatsby because its ignore includes node_modules where gatsby is npm installed (as per babel/babel#1270, babel/babel#1889 as you referenced).

Some solutions that I couldn't get to work are:

reverse ignore gatsby:

require('babel/register')({
  ignore: /node_modules\/(?!gatsby)/
});

or explicitly include

require("babel/register")({
  only: ["gatsby/lib"]
});

use env babel-node*

#!/usr/bin/env babel-node

spawn a child process/command*

./node_modules/.bin/babel-node --harmony ./bin/cli.js

*Note: both babel-node based solutions are not meant for production use.

Last one, that is the advised solution is to

precompile, i.e.:

"compile": "coffee --output dist --compile lib && babel -d dist/ lib/",
"prepublish": "npm run compile"

that would require some project restructuring.

from gatsby.

KyleAMathews avatar KyleAMathews commented on April 28, 2024

Thanks for your research! Yeah, precompile is doable but takes some careful setup.

from gatsby.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.