I have a script like "start": "node -r @babel/register ./src/start.js"
and I want to pass in the rootMode
option to @babel/register
to have it find my config file. If I were requireing @babel/register
in a file. I could do require('@babel/register')({rootMode: 'upward'})
. However I don't want to have an entrypoint script to each file like this.
Is there a way to pass options to babel register when requiring in command line node?
Just create register.js
file like a
//register.js
require('@babel/register')({rootMode: 'upward'})
and then use script "start": "node -r ./register.js ./src/start.js"
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.