babel command converts when run in terminal but running the script ends in error

106
January 12, 2022, at 1:50 PM

I've been trying to get babel core and cli to convert modern JavaScript from index.js into bundle.js.

here is my simple package.json

{
    "name": "chapter19",
    "version": "1.0.0",
    "description": "",
    "main": "index.js",
    "scripts": {
        "babel": "./node_modules/.bin/babel ./src/index.js -w -o ./dist/assets/bundle.js"
    },
    "author": "",
    "license": "ISC",
    "devDependencies": {
        "@babel/cli": "^7.16.7",
        "@babel/core": "^7.16.7",
        "@babel/preset-env": "^7.16.7",
        "babel-loader": "^8.2.3"
    }
}

now when I run node_modules/.bin/babel ./src/index.js -w -o ./dist/assets/bundle.js in terminal, it works fine but when I try to run "npm run babel" in terminal, I get the following errors. so far here is what I've tried :

"babel": "node_modules/.bin/babel src/index.js -w -o dist/assets/bundle.js"

result: 'node_modules' is not recognized as an internal or external command, operable program or batch file.

"babel": "./node_modules/.bin/babel src/index.js -w -o dist/assets/bundle.js"

result:'.' is not recognized as an internal or external command, operable program or batch file.

I have also read this issue, which is basically:

"babel": "node ./node_modules/.bin/babel src/index.js -w -o dist/assets/bundle.js"

OR

"babel": "node ./node_modules/.bin/babel ./src/index.js -w -o ./dist/assets/bundle.js"

and I get the following error:

SyntaxError: missing ) after argument list
    at Object.compileFunction (node:vm:352:18)
    at wrapSafe (node:internal/modules/cjs/loader:1031:15)
    at Module._compile (node:internal/modules/cjs/loader:1065:27)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
    at Module.load (node:internal/modules/cjs/loader:981:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
    at node:internal/main/run_main_module:17:47

here is my folder structure (in case if its needed)

Answer 1

For those who are interested in resolving this issue, in Windows you can use the following:

"scripts": {
    "babel": ".\\node_modules\\.bin\\babel src\\index.js -w -o dist\\assets\\bundle.js"
},
Rent Charter Buses Company
READ ALSO
codeigniter 4 / how to select emoji from mysql db and display in view

codeigniter 4 / how to select emoji from mysql db and display in view

I have a table called mh_countryHere is one row from phpmyadmin

129
How to prevent visitors or bots submitting a certain message that contain a certain string?

How to prevent visitors or bots submitting a certain message that contain a certain string?

I have a message box at the bottom of my siteI don't know how these messages manage to slip through my validations

92
/temp folder Writable	No (Make temp folder writable) - Permissions 755

/temp folder Writable No (Make temp folder writable) - Permissions 755

I am trying to install a web app on my Cpanel but I am having a challenge with the above server requirementHow do I solve it? Attached is a screenshot/temp folder Writable No (Make temp folder writable) - Permissions 755 of the problem

114
React native with Expo Framework don't show View and Titles

React native with Expo Framework don't show View and Titles

I’m doing a React Native application through the Expo frameworkIf I see through the Web, everything works correctly, while if I use the Android emulator (installed with Android Studio) it doesn’t make me view the information inside the View, but simply...

128