Skip to content

Fix npm publish babel error

Daan Eduard Rosendal requested to merge fix_npm_publish_babel_error into master

Fixes the following error when running npm publish

> lhcb-ntuple-wizard@1.0.1 prepublishOnly
> npm run transpile


> lhcb-ntuple-wizard@1.0.1 transpile
> babel src -d dist --copy-files

SyntaxError: /home/dfitz11/Desktop/ntuple_wizard/npm_deploy/lhcb-ntuple-wizard-frontend/src/components/App.jsx: Support for the experimental syntax 'jsx' isn't currently enabled (49:13):

  47 |     render() {
  48 |         return (
> 49 |             <>
     |             ^
  50 |                 <Navbar collapseOnSelect expand="lg" bg="dark" variant="dark">
  51 |                     <Container>
  52 |                         <Navbar.Brand href="/">

Add @babel/preset-react (https://github.com/babel/babel/tree/main/packages/babel-preset-react) 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://github.com/babel/babel/tree/main/packages/babel-plugin-syntax-jsx) to the 'plugins' section to enable parsing.
    at instantiate (/home/dfitz11/Desktop/ntuple_wizard/npm_deploy/lhcb-ntuple-wizard-frontend/node_modules/@babel/parser/lib/index.js:653:32)
    at constructor (/home/dfitz11/Desktop/ntuple_wizard/npm_deploy/lhcb-ntuple-wizard-frontend/node_modules/@babel/parser/lib/index.js:947:12)
    at Parser.raise (/home/dfitz11/Desktop/ntuple_wizard/npm_deploy/lhcb-ntuple-wizard-frontend/node_modules/@babel/parser/lib/index.js:3261:19)
    at Parser.expectOnePlugin (/home/dfitz11/Desktop/ntuple_wizard/npm_deploy/lhcb-ntuple-wizard-frontend/node_modules/@babel/parser/lib/index.js:3307:18)
    at Parser.parseExprAtom (/home/dfitz11/Desktop/ntuple_wizard/npm_deploy/lhcb-ntuple-wizard-frontend/node_modules/@babel/parser/lib/index.js:11220:18)
    at Parser.parseExprSubscripts (/home/dfitz11/Desktop/ntuple_wizard/npm_deploy/lhcb-ntuple-wizard-frontend/node_modules/@babel/parser/lib/index.js:10870:23)
    at Parser.parseUpdate (/home/dfitz11/Desktop/ntuple_wizard/npm_deploy/lhcb-ntuple-wizard-frontend/node_modules/@babel/parser/lib/index.js:10853:21)
    at Parser.parseMaybeUnary (/home/dfitz11/Desktop/ntuple_wizard/npm_deploy/lhcb-ntuple-wizard-frontend/node_modules/@babel/parser/lib/index.js:10829:23)
    at Parser.parseMaybeUnaryOrPrivate (/home/dfitz11/Desktop/ntuple_wizard/npm_deploy/lhcb-ntuple-wizard-frontend/node_modules/@babel/parser/lib/index.js:10667:61)
    at Parser.parseExprOps (/home/dfitz11/Desktop/ntuple_wizard/npm_deploy/lhcb-ntuple-wizard-frontend/node_modules/@babel/parser/lib/index.js:10672:23) {
  code: 'BABEL_PARSE_ERROR',
  reasonCode: 'MissingOneOfPlugins',
  loc: Position { line: 49, column: 12, index: 2024 },
  pos: [Getter/Setter],
  missingPlugin: [Getter/Setter]
}
npm ERR! code 1
npm ERR! path /home/dfitz11/Desktop/ntuple_wizard/npm_deploy/lhcb-ntuple-wizard-frontend
npm ERR! command failed
npm ERR! command sh -c npm run transpile

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/dfitz11/.npm/_logs/2023-04-25T22_34_12_570Z-debug-0.log

Merge request reports