https://github.com/orgs/vercel/discussions/7508 https://github.com/orgs/vercel/discussions/3168
Dear fork,
I deploy a simple express.js to vercel but it does not work.
index.js
const express = require('express');
const app = express();
const path = require('path')app.use(express.static(path.join(__dirname, '../static')));app.get('/*', function(req, res){ res.sendFile("index.html", {root: path.join(__dirname, '../static')});});
app.get('/api', (req, res) => { res.send('Hello from Express.js!');});
const PORT = process.env.PORT || 3000;app.listen(PORT, () => { console.log(`Server is running on port ${PORT}`); console.log('Press Ctrl+C to quit.');});In static folder, i have some JS files, the vercel build add some lines into the file ~~
Object.defineProperty(exports, "__esModule", { value: true});I try to add type: "module" in package.json but all server will die.
Log:
Running "vercel build"Vercel CLI 35.2.1WARN! Due to `builds` existing in your configuration file, the Build and Development Settings defined in your Project Settings will not apply. Learn More: https://vercel.link/unused-build-settingsInstalling dependencies...up to date in 1s12 packages are looking for funding run `npm fund` for detailsWarning: Node.js functions are compiled from ESM to CommonJS. If this is not intended, add "type": "module" to your package.json file.Compiling "index.js" from ESM to CommonJS...Compiling "bootstrap.esm.min.js" from ESM to CommonJS...Compiling "bootstrap.esm.js" from ESM to CommonJS...Compiling "start.js" from ESM to CommonJS...Build Completed in /vercel/output [1m]Deploying outputs...I want to compile only "index.js" from ESM to CommonJS. But vercel compile all file ~~
vercel.json
{ "version": 2, "cleanUrls": true, "framework": null, "installCommand": "npm install", "outputDirectory": ".", "public": false, "builds": [ { "src": "/src/index.js", "use": "@vercel/node" } ], "rewrites": [{ "source": "/(.*)", "destination": "/src/index.js" }]}The same issue but no answer: https://github.com/orgs/vercel/discussions/3168 I think is a vercel bug?
Please help me ~~ there is no document for this issue. Many thanks
