Question

How To resolve Unexpected token issue.

Posted July 2, 2021 225 views
React

I have an issue with npm run dev.

> my-react-app@0.1.0 dev /home/webdev/myworkstation/SSR-Sample/my-react-app

> npm-run-all --parallel build dev:*


> my-react-app@0.1.0 dev:build-server /home/webdev/myworkstation/SSR-Sample/my-react-app
> NODE_ENV=production webpack --config webpack.server.js --mode=production -w


> my-react-app@0.1.0 build /home/webdev/myworkstation/SSR-Sample/my-react-app
> react-scripts build


> my-react-app@0.1.0 dev:start /home/webdev/myworkstation/SSR-Sample/my-react-app
> node ./server/index.js

file:///home/webdev/myworkstation/SSR-Sample/my-react-app/server/index.js:26
        `<div id="root">${ReactDOMServer.renderToStaticMarkup(<App/>)}</div>`
                                                              ^

SyntaxError: Unexpected token '<'
    at Loader.moduleStrategy (internal/modules/esm/translators.js:145:18)
    at async link (internal/modules/esm/module_job.js:47:21)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! my-react-app@0.1.0 dev:start: `node ./server/index.js`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the my-react-app@0.1.0 dev:start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/webdev/.npm/_logs/2021-07-02T20_18_27_972Z-debug.log
ERROR: "dev:start" exited with 1.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! my-react-app@0.1.0 dev: `npm-run-all --parallel build dev:*`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the my-react-app@0.1.0 dev script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/webdev/.npm/_logs/2021-07-02T20_18_28_039Z-debug.log
edited by bobbyiliev
Submit an answer

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!