Why is the code after babel transcoding not written to the file and only output in the console?

The code in

testBabel is only output in the console after transcoding with babel, and the compile.js is still blank
clipboard.png

npm run babel node_modules/.bin/babel
clipboard.png

.
Apr.13,2022

solved.
my babel is installed locally. For convenience, I added a script-- "babel": "node_modules/.bin/babel" in package.json so that when transcoding a file, I don't have to enter a long string of "node_modules/.bin/babel", and then I want to transcode the file through npm run babel index.js-o compile.js. Later, I found that this would only transcode two files and output them to the console.
then change it back to "node_modules/.bin/babel index.js-o compile.js". It seems that I took it for granted before.
but why this happened is not clear. Welcome to add ~

.
Menu