Gatsby: Spawned Process doesn't pass node arguments down

Created on 11 Jun 2020  路  3Comments  路  Source: gatsbyjs/gatsby

I'm using esm to use ES modules in gatsby-[ssr,node,config].js and I have used it like so for over a year:

"build": "npx --node-arg '-r esm' gatsby build",
"develop": "npx --node-arg '-r esm' gatsby develop",

Something changed recently and none of these projects will build, I get the errors about not being allowed to use import/export.

A replication can be found here: https://github.com/reaktivo/gatsby-esm/issues/1

@marcysutton confirmed the issue: https://twitter.com/marcysutton/status/1270828197588787200

@ascorbic has suggested to try NODE_OPTIONS env variable because apparently develop now runs in a spawned processs? https://twitter.com/ascorbic/status/1270836362602741760

@mxstbr has said it was him that broke it 馃ぃ https://twitter.com/mxstbr/status/1270836603410419716

Thanks a ton! Let me know if I can offer any more help.

confirmed cli bug

Most helpful comment

The above worked with the latest version of gatsby! Thanks

All 3 comments

Thank you for the detailed issue! :pray:

This very likely broke because of #22759, similar to #24349. I'm wondering if there's a way to pass all node options through to the child process in order to preserve all this functionality...

thanks Max - I've tried getting it working with NODE_OPTIONS but that doesn't seem to work. Does anyone know if I'm doing this right? Or maybe it just doesn't get passed down at all?

"develop": "NODE_OPTIONS='-r esm' gatsby develop",

The above worked with the latest version of gatsby! Thanks

Was this page helpful?
0 / 5 - 0 ratings

Related issues

totsteps picture totsteps  路  3Comments

kalinchernev picture kalinchernev  路  3Comments

mikestopcontinues picture mikestopcontinues  路  3Comments

3CordGuy picture 3CordGuy  路  3Comments

Oppenheimer1 picture Oppenheimer1  路  3Comments