Sublime Forum

How to run build with babel-node instead of node

#1

this is my build

{
  "cmd": ["/usr/local/bin/babel-node", "$file"],
  "selector": "source.js"
}

this is my test.js file

function whatup(){
	let a = 1
	return a
}
console.log('hello')

When I run build, I got this error in the sublime console

/usr/local/lib/node_modules/@babel/core/lib/config/config-descriptors.js:178
    throw new Error(`Plugin/Preset files are not allowed to export objects, only functions. In ${filepath}`);
    ^

Error: Plugin/Preset files are not allowed to export objects, only functions. In /Users/craigcosmo/Dropbox/Code/js-play/node_modules/babel-preset-es2015/lib/index.js
    at createDescriptor (/usr/local/lib/node_modules/@babel/core/lib/config/config-descriptors.js:178:11)
    at items.map (/usr/local/lib/node_modules/@babel/core/lib/config/config-descriptors.js:109:50)
    at Array.map (<anonymous>)
    at createDescriptors (/usr/local/lib/node_modules/@babel/core/lib/config/config-descriptors.js:109:29)
    at createPresetDescriptors (/usr/local/lib/node_modules/@babel/core/lib/config/config-descriptors.js:101:10)
    at presets (/usr/local/lib/node_modules/@babel/core/lib/config/config-descriptors.js:47:19)
    at mergeChainOpts (/usr/local/lib/node_modules/@babel/core/lib/config/config-chain.js:320:26)
    at /usr/local/lib/node_modules/@babel/core/lib/config/config-chain.js:283:7
    at buildRootChain (/usr/local/lib/node_modules/@babel/core/lib/config/config-chain.js:120:22)
    at loadPrivatePartialConfig (/usr/local/lib/node_modules/@babel/core/lib/config/partial.js:85:55)
[Finished in 0.7s with exit code 1]
[cmd: ['/usr/local/bin/babel-node', '/Users/craigcosmo/Dropbox/Code/js-play/just.js']]
[dir: /Users/craigcosmo/Dropbox/Code/js-play]
[path: /Library/Frameworks/Python.framework/Versions/3.7/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/go/bin]
0 Likes

#2

It DID being executed with /usr/local/bin/babel-node as shown in the error log.

[cmd: ['/usr/local/bin/babel-node', '/Users/craigcosmo/Dropbox/Code/js-play/just.js']]

I just installed @babel/node and using your test script and build command. It ran successfully.

babel-preset-es2015 is a quite old and deprecated preset while you are using @babel which is the latest core. People are using @babel/preset-env nowadays. I guess the problem is your babel env setup. There is nothing to do with Sublime Text.

1 Like