Skip to content

Unexpected token when using "node server.js" with transpiled express server #715

@Angel200O

Description

@Angel200O

I am using babel to transpile everything into a build folder, if i try running server.js with
cd build
node server.js
I get this error
SyntaxError: C:/web-liga/node_modules/next/dist/pages/_error-debug.js?entry: Unexpected token (14:11)

  12 |     const { name, message, stack, path } = this.props
  13 |
> 14 |     return <div className='errorDebug'>
     |            ^
  15 |       <Head>
  16 |         <meta name='viewport' content='width=device-width, initial-scale=1.0' />
  17 |       </Head>

But if i run the server using "npm run dev"

"scripts": {
    "build": "node_modules/.bin/babel ./ --out-dir build -s --ignore node_modules",
    "clean": "rm -rf build && mkdir build",
    "dev": "npm run clean && npm run build && npm run watch",
    "start": "NODE_ENV=production node build/server.js",
    "watch": "node_modules/.bin/babel-watch --exclude components --exclude pages --exclude .next build/server.js"
  }

Everything runs perfectly except that .next is getting compiled outside of the build folder because thats where im running npm from

All of this brings problems when trying to deploy to heroku or now

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions