Beginner's question: create command-line tool


#1

Hi, I know this is most likely not an Expo-specific question, but I hope my newbie question has an easy answer. I have an Expo project with lots of dependencies and custom code, e.g. to connect to database, process data, etc. Everything works great. I’m now trying to create a ‘createDb’ command-line tool to populate the database with initial data. That command-line tool needs to reuse some of the other code, which use Babel to transpile newer keywords like async/await, import, etc. I tried to run it using node (latest 8.x LTS), but realized it doesn’t recognize these newer keywords. Do I really need to install babel-cli, and possibly have to create a new package.json, .babelrc, etc. (that I’d need to keep in sync) - or is there a simpler way? Thank you,

Christian


#2

Hi @claforte, async/await should work on node 8 – double check that you’ve got the correct version?

Regarding your question – installing babel-cli is highly recommended, and you’ll need to make sure that everything all transpiles down to the compatible javascript you are working with.


#3

Thank you Quinlanj, I appreciate your advice!

For the time being I simply replaced the ‘import’ and ‘export’ by the older keywords ‘require()’ and ‘modules.export’. I didn’t need to change the async/await. Next time I bump into this kind of problem (and have a bit more time) I will try babel-cli. Thank you very much and have a great day!

Christian


closed #4

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.