Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/468.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/node.js/33.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 将Nodejs部署到Heroku:babel(es6)出错_Javascript_Node.js_Reactjs_Heroku_Babeljs - Fatal编程技术网

Javascript 将Nodejs部署到Heroku:babel(es6)出错

Javascript 将Nodejs部署到Heroku:babel(es6)出错,javascript,node.js,reactjs,heroku,babeljs,Javascript,Node.js,Reactjs,Heroku,Babeljs,我在部署应用程序时从heroku控制台中发现了这个错误。 它在本地工作,但无法部署 SyntaxError: /tmp/build_4b397c70/.heroku/node/lib/node_modules/npm/docs/gatsby-browser.js: Support for the experimental syntax 'jsx' isn't currently enabled (7:10): 5 | 6 | export const wrapPageElement =

我在部署应用程序时从heroku控制台中发现了这个错误。 它在本地工作,但无法部署

SyntaxError: /tmp/build_4b397c70/.heroku/node/lib/node_modules/npm/docs/gatsby-browser.js: Support for the experimental syntax 'jsx' isn't currently enabled (7:10):
  5 |
  6 | export const wrapPageElement = ({ element, props }) => {
> 7 |   return <Layout {...props} >{element}</Layout>
    |          ^
  8 | }
  9 |
Add @babel/preset-react (https://git.io/JfeDR) to the 'presets' section of your Babel config to enable transformation.
If you want to leave it as-is, add @babel/plugin-syntax-jsx (https://git.io/vb4yA) to the 'plugins' section to enable parsing.
    at Parser._raise (/tmp/build_4b397c70/node_modules/@babel/parser/lib/index.js:810:17)
    at Parser.raiseWithData (/tmp/build_4b397c70/node_modules/@babel/parser/lib/index.js:803:17)
    at Parser.expectOnePlugin (/tmp/build_4b397c70/node_modules/@babel/parser/lib/index.js:9982:18)
    at Parser.parseExprAtom (/tmp/build_4b397c70/node_modules/@babel/parser/lib/index.js:11367:22)
    at Parser.parseExprSubscripts (/tmp/build_4b397c70/node_modules/@babel/parser/lib/index.js:10941:23)
    at Parser.parseUpdate (/tmp/build_4b397c70/node_modules/@babel/parser/lib/index.js:10921:21)
    at Parser.parseMaybeUnary (/tmp/build_4b397c70/node_modules/@babel/parser/lib/index.js:10899:23)
    at Parser.parseExprOps (/tmp/build_4b397c70/node_modules/@babel/parser/lib/index.js:10756:23)
    at Parser.parseMaybeConditional (/tmp/build_4b397c70/node_modules/@babel/parser/lib/index.js:10730:23)
    at Parser.parseMaybeAssign (/tmp/build_4b397c70/node_modules/@babel/parser/lib/index.js:10693:21) {
  loc: Position { line: 7, column: 9 },
  pos: 209,
  missingPlugin: [ 'jsx', 'flow', 'typescript' ],
  code: 'BABEL_PARSE_ERROR'
}
.babelrc

{
  "presets": ["@babel/preset-env"],
  "plugins": [
      ["@babel/transform-runtime"]
  ]
}
我在babel配置的“presets”部分添加了@babel/preset react,但仍然得到了相同的错误


注意:这是一个简单的nodejs服务器api,不是react api,但错误表明使用了preset react。

我认为您缺少了一个巴贝尔preset react配置,Heroku可能会使用它“到您的巴贝尔配置的“presets”部分以启用转换”这一行我的意思是参考这里的文档,看看它可能是什么
{
  "presets": ["@babel/preset-env"],
  "plugins": [
      ["@babel/transform-runtime"]
  ]
}