gatsby new TypeError: initStarter is not a function

Created on 11 Mar 2020  ·  17Comments  ·  Source: gatsbyjs/gatsby

Description

Can't start new gatsby project

Steps to reproduce

gatsby new hello-world https://github.com/gatsbyjs/gatsby-starter-hello-world

Expected result

Start new gatsby project

Actual result

gatsby new hello-world https://github.com/gatsbyjs/gatsby-starter-hello-world  ✔ | at 19:49:37 
/usr/local/lib/node_modules/gatsby-cli/node_modules/yoga-layout-prebuilt/yoga-layout/build/Release/nbind.js:53
throw ex;
^

TypeError: initStarter is not a function
at /usr/local/lib/node_modules/gatsby-cli/lib/create-cli.js:334:14
at Object.handler (/usr/local/lib/node_modules/gatsby-cli/lib/create-cli.js:32:19)
at Object.runCommand (/usr/local/lib/node_modules/gatsby-cli/node_modules/yargs/lib/command.js:238:44)
at Object.parseArgs [as _parseArgs] (/usr/local/lib/node_modules/gatsby-cli/node_modules/yargs/yargs.js:1063:30)
at Object.parse (/usr/local/lib/node_modules/gatsby-cli/node_modules/yargs/yargs.js:566:25)
at module.exports (/usr/local/lib/node_modules/gatsby-cli/lib/create-cli.js:388:6)
at Object. (/usr/local/lib/node_modules/gatsby-cli/lib/index.js:141:24)
at Module._compile (internal/modules/cjs/loader.js:1147:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1167:10)
at Module.load (internal/modules/cjs/loader.js:996:32)

Environment

System:
OS: macOS 10.15.3
CPU: (8) x64 Intel(R) Core(TM) i7-4770HQ CPU @ 2.20GHz
Shell: 5.7.1 - /bin/zsh
Binaries:
Node: 13.10.1 - /usr/local/bin/node
npm: 6.14.2 - /usr/local/bin/npm
Languages:
Python: 2.7.16 - /usr/bin/python
Browsers:
Chrome: 80.0.3987.132
Firefox: 73.0.1
Safari: 13.0.5
npmGlobalPackages:
gatsby-cli: 2.10.5

bug

Most helpful comment

Quick workaround from someone trying gatsby for the first time and not wanting to give up here - removed 2.10.5 and installed [email protected] (npm install -g [email protected])

All 17 comments

Bumping. Even just a new site isn't working on [email protected]

->$ gatsby new test-site
/usr/local/lib/node_modules/gatsby-cli/node_modules/yoga-layout-prebuilt/yoga-layout/build/Release/nbind.js:53
        throw ex;
        ^

TypeError: initStarter is not a function
    at /usr/local/lib/node_modules/gatsby-cli/lib/create-cli.js:334:14
    at Object.handler (/usr/local/lib/node_modules/gatsby-cli/lib/create-cli.js:32:19)
    at Object.runCommand (/usr/local/lib/node_modules/gatsby-cli/node_modules/yargs/lib/command.js:238:44)
    at Object.parseArgs [as _parseArgs] (/usr/local/lib/node_modules/gatsby-cli/node_modules/yargs/yargs.js:1063:30)
    at Object.parse (/usr/local/lib/node_modules/gatsby-cli/node_modules/yargs/yargs.js:566:25)
    at module.exports (/usr/local/lib/node_modules/gatsby-cli/lib/create-cli.js:388:6)
    at Object.<anonymous> (/usr/local/lib/node_modules/gatsby-cli/lib/index.js:141:24)
    at Module._compile (internal/modules/cjs/loader.js:1147:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1167:10)
    at Module.load (internal/modules/cjs/loader.js:996:32)

Quick workaround from someone trying gatsby for the first time and not wanting to give up here - removed 2.10.5 and installed [email protected] (npm install -g [email protected])

I have the same error with the following environment:
node: 10.17.0
npm: 6.13.6
OS: Ubuntu 19.10 (5.3.40 kernel)

Same problem here. I decided to install the previous version (2.10.4)

Same problem. I installed Gatsby for the first time 5 minutes ago and encountered this.

Encountering this as well. Tried downgrading, but now the SSR bundle is failing.

Generating SSR bundle failed

[BABEL] /.../dev/my-hello-world-starter/.cache/develop-static-entry.js: No "exports" main resolved in .../dev/my-hello-world-starter/node_modules/@babel/helper-compilation-targets/package.json

I've tried deleting my node_modules and re-installing, but no dice. I am using yarn if that matters.

Encountering this as well. Tried downgrading, but now the SSR bundle is failing.

Generating SSR bundle failed

[BABEL] /.../dev/my-hello-world-starter/.cache/develop-static-entry.js: No "exports" main resolved in .../dev/my-hello-world-starter/node_modules/@babel/helper-compilation-targets/package.json

I've tried deleting my node_modules and re-installing, but no dice. I am using yarn if that matters.

just run npm i @babel/helper-compilation-targets

npm i @babel/helper-compilation-targets

🤦‍♂ Thank you.

Same problem here!

Solved after downgrading to 2.10.4:

npm uninstall -g gatsby-cli
npm install -g [email protected]

I just published @blainekasten's PR — sorry about the breakage everyone! If you upgrade to the latest gatsby-cli (npm install -g gatsby-cli) things will work again.

Happy Gatsbying

@KyleAMathews I've just run into the same BABEL ... No "exports" main resolved in issue when running npm gatsby new. Isn't that supposed to pull the latest CLI?

@fcsm82: can you please edit the title of this bug to mention exactly what's wrong with "gatsby new"? A lot of people are searching for this issue, and its title could be more helpful. Thanks!

@fcsm82: can you please edit the title of this bug to mention exactly what's wrong with "gatsby new"? A lot of people are searching for this issue, and its title could be more helpful. Thanks!

How about "gatsby new TypeError: initStarter is not a function" ?

I just published @blainekasten's PR — sorry about the breakage everyone! If you upgrade to the latest gatsby-cli (npm install -g gatsby-cli) things will work again.

Happy Gatsbying

Installing gatsby-cli has fixed the issue for me! Thank you!

Why is this closed when the bug is not fixed? Installed gatsby-cli today [email protected]
\AppData\Roaming\npmnode_modules\gatsby-cli\lib\init-starter.js:117
} catch {
^

SyntaxError: Unexpected token {
at createScript (vm.js:80:10)
at Object.runInThisContext (vm.js:139:10)
at Module._compile (module.js:617:28)
at Object.Module._extensions..js (module.js:664:10)
at Module.load (module.js:566:32)
at tryModuleLoad (module.js:506:12)
at Function.Module._load (module.js:498:3)
at Module.require (module.js:597:17)
at require (internal/module.js:11:18)
at Object. (C:\Users\jost\AppData\Roaming\npmnode_modules\gatsby-cli\lib\create-cli.js:28:20)

Why is this closed when the bug is not fixed?

Many issues in this repo are closed due to a repo policy (and bots to enforce it) to automatically close issues without activity (30 days between comments), even if the lack of activity is due to no solution being found.

At the same time, issues with pointless activity (e.g. "Thanks") stay open if they are active.

This issue was closed by Kyle though, so let's see if he replies.

@endasil: one way to reopen this issue would be to make a contribution to Gatsby. All contributors are invited to the org. Once invited, the "Reopen issue" button will become available.

@endasil - Just ran into the same thing and upgrading NodeJS seems to have fixed the issue. I was running 8.16 and upgraded to stable (14.4).

That new people wanting to try Gatsby and/or recommend it for development can't run the basic tutorial from the starter page seems a significant issue to want to resolve? I'm getting the above problem and no clear remedy and was intending to introduce gatsby as a preferred framework for a developer team. That's looking difficult now.

Was this page helpful?
0 / 5 - 0 ratings