"loose": true is not fix 对实验性语法 'classProperties' 的支持当前未启用
Posted
技术标签:
【中文标题】"loose": true is not fix 对实验性语法 \'classProperties\' 的支持当前未启用【英文标题】:"loose": true is not fixing Support for the experimental syntax 'classProperties' isn't currently enabled"loose": true is not fix 对实验性语法 'classProperties' 的支持当前未启用 【发布时间】:2019-11-10 18:35:32 【问题描述】:目前不支持实验性语法“classProperties” 启用
我尝试了解决方案,重新构建后仍然出现错误。
Support for the experimental syntax 'classProperties' isn't currently enabled
package.json
"name": "blahmodule",
"version": "1.0.0",
"description": "a fetch module for our project",
"main": "index.js",
"scripts":
"test": "echo \"Error: no test specified\" && exit 1",
"build": "./node_modules/.bin/babel src --out-file index.js"
,
"peerDependencies":
"react": "^16.6.6",
"react-dom": "^16.6.3",
"axios": "^0.19.0"
,
"author": "",
"license": "ISC",
"dependencies":
"@babel/cli": "^7.4.4",
"@babel/core": "^7.4.5",
"@babel/preset-env": "^7.4.5",
"@babel/preset-react": "^7.0.0",
"react": "^16.8.6",
"react-dom": "^16.8.6"
,
"devDependencies":
"@babel/plugin-proposal-class-properties": "^7.4.4",
"axios": "^0.19.0"
.babelrc
"presets": [
"@babel/preset-env",
"@babel/preset-react"
],
"plugins": [
[
"@babel/plugin-proposal-class-properties",
"loose": true
]
]
【问题讨论】:
【参考方案1】:你必须安装
npm install @babel/core @babel/plugin-proposal-class-properties @babel/preset-env @babel/preset-react babel-loader
和
更改输入和输出
const path = require('path')
module.exports =
entry: path.resolve(__dirname,'src', 'app.js'),
output:
path: path.resolve(__dirname, "public","dist",'javascript'),
filename: 'bundle.js'
,
module:
rules: [
test: /\.(jsx|js)$/,
exclude: /node_modules/,
use: [
loader: 'babel-loader',
options:
presets: [
['@babel/preset-env',
"targets": "defaults"
],
'@babel/preset-react'
],
plugins: [
"@babel/plugin-proposal-class-properties"
]
]
]
【讨论】:
【参考方案2】:我正在使用plugin-proposal-class-propterties
,它可以工作,这是我的 JSON 配置文件.babelrc
"presets": ["@babel/preset-env"],
"plugins": [
[
"@babel/plugin-proposal-class-properties",
"loose": true
]
]
【讨论】:
【参考方案3】:尝试创建一个文件babel.config.js
并使用module.exports
导出配置。我也相信您不需要loose
选项:
babel.config.js
:
module.exports =
presets: ["@babel/preset-env", "@babel/preset-react"],
plugins: ["@babel/plugin-proposal-class-propterties"]
;
【讨论】:
我得到.loose is not a valid Plugin property
当我松手时它会生成,让我看看这是否能解决问题。
所以也许你不需要loose
使用我上面描述的方法?等一下,正在编辑...
解决方案仍然无法修复Support for the experimental syntax 'classProperties' isn't currently enabled
以上是关于"loose": true is not fix 对实验性语法 'classProperties' 的支持当前未启用的主要内容,如果未能解决你的问题,请参考以下文章
R 语言这个错误,如何解决?missing value where TRUE/FALSE needed
jquery代码 求解释,不大明白的是if(i==1)那一行还有$(".ci_div"+i+" .wrap"),