Reputation: 1
I am trying to convert PHP script to js using babel-preset-php
but I am getting this error-
Error: Plugin 0 specified in "/media/deep/5738c180-2397-451b-b0b5-df09b7ad951e1/deepx/Documents/TestingAll/node_modules/babel-preset-php/src/index.js" provided an invalid property of "default" (While processing preset: "/media/deep/5738c180-2397-451b-b0b5-df09b7ad951e1/deepx/Documents/TestingAll/node_modules/babel-preset-php/src/index.js")
at Plugin.init (/usr/local/lib/node_modules/babel-cli/node_modules/babel-core/lib/transformation/plugin.js:131:13)
at Function.normalisePlugin (/usr/local/lib/node_modules/babel-cli/node_modules/babel-core/lib/transformation/file/options/option-manager.js:152:12)
at /usr/local/lib/node_modules/babel-cli/node_modules/babel-core/lib/transformation/file/options/option-manager.js:184:30
at Array.map (<anonymous>)
at Function.normalisePlugins (/usr/local/lib/node_modules/babel-cli/node_modules/babel-core/lib/transformation/file/options/option-manager.js:158:20)
at OptionManager.mergeOptions (/usr/local/lib/node_modules/babel-cli/node_modules/babel-core/lib/transformation/file/options/option-manager.js:234:36)
at /usr/local/lib/node_modules/babel-cli/node_modules/babel-core/lib/transformation/file/options/option-manager.js:265:14
at /usr/local/lib/node_modules/babel-cli/node_modules/babel-core/lib/transformation/file/options/option-manager.js:323:22
at Array.map (<anonymous>)
at OptionManager.resolvePresets (/usr/local/lib/node_modules/babel-cli/node_modules/babel-core/lib/transformation/file/options/option-manager.js:275:20)
I installed the preset with npm i -S babel-preset-php
.
I set .babelrc
to
{
"presets": ["php"]
}
I installed the CLI with npm i -g babel-cli
. Then I created a simple PHP file that only contains simple code:
<?php
echo "hello world";
And when I run the transpiler with babel file.php -o file.js
, I am getting that error.
package.json
-
{
"name": "testingall",
"version": "1.0.0",
"description": "",
"main": "script.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"axios": "^0.21.1",
"babel-core": "^6.26.3",
"babel-loader": "^8.2.2",
"babel-plugin-transform-flow-strip-types": "^6.22.0",
"babel-preset-php": "^2.0.0",
"body-parser": "^1.19.0",
"compression": "^1.7.4",
"cors": "^2.8.5",
"dotenv": "^9.0.2",
"express": "^4.17.1",
"express-rate-limit": "^5.2.6",
"pug": "^3.0.2",
"superagent": "^6.1.0"
}
}
node version - v12.18.4
.
babel version - 6.26.0 (babel-core 6.26.3)
How can solve that?
Upvotes: 0
Views: 192
Reputation: 161657
"babel-preset-php": "^2.0.0",
is for Babel 7.x. Since you've installed Babel 6.x, you need to use
"babel-preset-php": "^1.0.0",
Upvotes: 1