ahmadawais / create-guten-block

📦 A zero-configuration #0CJS developer toolkit for building WordPress Gutenberg block plugins.
https://Awais.dev/cgb-post
MIT License
3.15k stars 328 forks source link

npm - start producing error SyntaxError: Unexpected token ... in cgb-scripts/config/externals.js:36 #258

Open bhuether opened 4 years ago

bhuether commented 4 years ago

Hi I am getting this error on MAC Sierra:

my-forum-block-cgb-guten-block@1.0.0 start /wp-content/plugins/my-forum-block

cgb-scripts start

/Library/WebServer/Documents/courses.guitar-dreams/wp-content/plugins/my-forum-block/node_modules/cgb-scripts/config/externals.js:36 ...externals, ^^^

SyntaxError: Unexpected token ... at createScript (vm.js:74:10) at Object.runInThisContext (vm.js:116:10) at Module._compile (module.js:533:28) at Object.Module._extensions..js (module.js:580:10) at Module.load (module.js:503:32) at tryModuleLoad (module.js:466:12) at Function.Module._load (module.js:458:3) at Module.require (module.js:513:17) at require (internal/module.js:11:18) at Object. (/Library/WebServer/Documents/courses.guitar-dreams/wp-content/plugins/my-forum-block/node_modules/cgb-scripts/config/webpack.config.dev.js:24:19)

My setup is

npm 6.13.1 npx 6.13.1 node v8.2.1

Haven't read about anyone seeing this error. I read that such an error can indicate that you need to add a spread transform plugin, but since this plugin is zero config I figure the problem probably lies elsewhere. Maybe something in my MAC node setup is causing the problem. Thoughts on what to look for?

Maybe problem caused by a previous plugin that I setup following this thread:

https://modularwp.com/how-to-build-gutenberg-blocks-jsx/

But I figured whatever that installed was local to the directory. With those instructions, I also ran into the spread operator issue, and solved it based on this:

https://github.com/babel/babel-loader/issues/170

But with this create-guten-block package (which is in different folder) I can't seem to resolve the error. I tried running

npm install --save-dev babel-plugin-transform-object-rest-spread

in the project folder and then adding a .babelrc with

"plugins": [ [ "transform-react-jsx", { "pragma": "wp.element.createElement" } ], ["transform-object-rest-spread"] ]

So curious what might be the root cause here, and what to do about it?

thanks, Brian