In a new app created with create-react-app
, how can I run a command-line script? The following fails:
$ npx create-react-app foo
[snip]
$ cd foo/
$ echo "import {App} from './src/App.js';" > test.js
$ node test.js
/private/tmp/foo/test.js:1
import {App} from './src/App.js';
^
SyntaxError: Unexpected token {
at Module._compile (internal/modules/cjs/loader.js:718:23)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:785:10)
at Module.load (internal/modules/cjs/loader.js:641:32)
at Function.Module._load (internal/modules/cjs/loader.js:556:12)
at Function.Module.runMain (internal/modules/cjs/loader.js:837:10)
at internal/main/run_main_module.js:17:11
I've tried running both babel-node
and node --harmony
. I just need some way to have the script run successfully whether it's changing the script or changing how I run it.