Vercel + Express.js 不提供 JS 文件

Vercel + Express.js don't serve JS files

我在 Vercel 上部署了一个 Express.js 服务器(使用 NowCLI),在我的 index.js 文件中,我使用 dash/assets 文件夹中的每个文件都在 assetsDash/ 提供服务 app.use('/assetsDash', express.static(path.join(__dirname, 'dash', 'assets'))) 这有效,但不提供 .js 文件(顺便说一句,这在本地主机上有效,但不适用于 Vercel)。

index.js

// Import FS and Path
const fs = require('fs')
const path = require('path')

// Prepare an web server using express.js
const express = require('express')
const app = express()

// Add pages to the website
    // Assets
    app.use('/assetsLanding', express.static(path.join(__dirname, 'landing', 'assets')))
    app.use('/assetsDash', express.static(path.join(__dirname, 'dash', 'assets')))

// Start the web server
const server = app.listen(process.env.PORT || 3000, () => {
    console.log(`Started on ${server.address().port} port`);
});

now.json

{
    "version": 2,
    "builds": [{
      "src": "./index.js",
      "use": "@now/node-server"
    }],
    "routes": [{"handle": "filesystem"},
      {
        "src": "/.*",
        "dest": "index.js"
      }
    ]
  }

编辑: 我设法通过用 VercelCLI 替换 NowCLI 来解决它:通过 NPM 安装 @vercel/node,然后将 now.json 文件重命名为 vercel.json 并替换文件中的一行。

"builds": [{
      "src": "./index.js",
-     "use": "@now/node-server"
+     "use": "@vercel/node"
}],