使用package.json设置“主”文件时,出现实验性语法错误,如果不是,则一切正常-
我在Laravel项目中进行了预设反应,并遇到实验性语法错误,最后通过修改根package.json解决了这个问题,但是当我决定将组件分成文件夹并为每个目录使用新的package.json时,我又开始得到这个错误。从文件夹中删除package.json文件后,一切正常
root package.json
{
"private": true,
"scripts": {
"dev": "npm run development",
"development": "cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js",
"watch": "npm run development -- --watch",
"watch-poll": "npm run watch -- --watch-poll",
"hot": "cross-env NODE_ENV=development node_modules/webpack-dev-server/bin/webpack-dev-server.js --inline --hot --config=node_modules/laravel-mix/setup/webpack.config.js",
"prod": "npm run production",
"production": "cross-env NODE_ENV=production node_modules/webpack/bin/webpack.js --no-progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js"
},
"babel": {
"presets": [
"@babel/preset-env",
"@babel/preset-react"
],
"plugins": [
"@babel/plugin-proposal-class-properties"
]
},
"devDependencies": {
"@babel/core": "^7.4.5",
"@babel/preset-env": "^7.4.5",
"@babel/preset-react": "^7.0.0",
"axios": "^0.18",
"babel-loader": "^8.0.6",
"bootstrap": "^4.1.0",
"cross-env": "^5.1",
"css-loader": "^3.0.0",
"html-webpack-plugin": "^3.2.0",
"jquery": "^3.2",
"laravel-mix": "^4.0.7",
"lodash": "^4.17.5",
"popper.js": "^1.12",
"react": "^16.8.6",
"react-dom": "^16.8.6",
"resolve-url-loader": "^2.3.1",
"sass": "^1.15.2",
"sass-loader": "^7.1.0",
"style-loader": "^0.23.1",
"webpack": "^4.35.0",
"webpack-cli": "^3.3.5",
"webpack-dev-server": "^3.7.2"
},
"dependencies": {
"@babel/plugin-proposal-class-properties": "^7.4.4"
}
}
在文件夹中使用时package.json
{
"main": "./Container.js"
}
错误
SyntaxError: C:\laravel\react-test\resources\js\components\Container\Container.js: Support for the experimental syntax 'classProperties' isn't currently enabled (14:12):
我想使用package.json,找不到解决方案
编辑 我从组件中的json文件中删除了所有内容
{
}
问题仍然存在,直到我删除整个文件,我猜想当在组件中使用时,react发现仅与json有关的问题