![](/img/trans.png)
[英]Babel React transform : Property value expected type of string but got null
[英]BABEL_TRANSFORM_ERROR. Property value expected type of string but got object
我使用了本教程https://www.vairix.com/tech-blog/server-side-rendering-ssr-of-create-react-app-cra-app-in-2020%C2%A0和以下示例 github回購https://github.com/dariomac/poc-cra-ssr
我的 bootstrap.js,我使用 node.js v12 並在 Google 中嘗試了所有可能的解決方案
require('ignore-styles');
require('@babel/register')({
"presets": [
"@babel/preset-env",
"@babel/preset-react"
],
"plugins": [
"@babel/plugin-proposal-class-properties",
//"@babel/plugin-transform-modules-commonjs",
[
"transform-assets",
{
"extensions": [
"css",
"svg"
],
"name": "static/media/[name].[hash:8].[ext]"
}
]
]
});
require('./index');
注意:自從 babel 抱怨以來,我已將其添加到 bootstrap.js 的插件中
"plugins": [
"@babel/plugin-proposal-class-properties",
//"@babel/plugin-transform-modules-commonjs",
使用您的 bootstrap.js 代碼,我在使用 Node v12.13.0 時沒有遇到任何問題。
我什至嘗試過一個空的、干凈的 CRA 項目,它沒有任何變化就可以工作。 我已將 Github 存儲庫的代碼更新為每個依賴項的最新版本。
請測試它,讓我知道是否解決了問題。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.