Reputation: 30443
I'm calling this command:
$ babel-node --presets react,es2015 server.js
but instead of running node and using Babel with the react and es2015 presets, I get this error:
Cannot find module 'C:\websites\rgrjs\react,es2015'
at Function.Module._resolveFilename (module.js:326:15)
at Function.Module._load (module.js:277:25)
at Function.Module.runMain (module.js:430:10)
at Object.<anonymous> (C:\Users\Tom\AppData\Roaming\npm\node_modules\babel\lib\_babel-node.js:144:25)
at Module._compile (module.js:398:26)
at Object.Module._extensions..js (module.js:405:10)
at Module.load (module.js:344:32)
at Function.Module._load (module.js:301:12)
at Function.Module.runMain (module.js:430:10)
at startup (node.js:141:18)
That seems to suggest that node is interpreting the react,es2015
parameters as a file instead of parameters for the presets option? How can I fix that?
The Babel documentation for babel-node
seems to use the same syntax as above? I've tried adding --
before the file name but that didn't help.
I'm pretty new to React and Node and am working through a course at the moment, so apologies if this is something blindingly obvious.
These are the dependencies in my package.json file:
"dependencies": {
"babel": "^6.3.26",
"babel-cli": "^6.4.0",
"babel-core": "^6.4.0",
"babel-loader": "^6.2.1",
"babel-preset-es2015": "^6.3.13",
"babel-preset-react": "^6.3.13",
"express": "^4.13.3",
"react": "^0.14.3",
"react-dom": "^0.14.3",
"webpack": "^1.12.9"
},
Edit As well as the accepted answer, it's also possible that this issue was down to my global version of babel being different to the project version and my not understanding which one node is using.
Upvotes: 2
Views: 9694
Reputation: 1309
Instead of using a ,
for separating the presets, have you tried separating it by space?
$ babel-node --presets react es2015 server.js
Or use .babelrc
instead?
{
"presets": ["react", "es2015"]
}
Upvotes: 2