我正在尝试部署我的应用程序,它是 next.js + express 服务器,只是为了处理一些套接字连接。
这是我的项目目录的样子:
next.config.js:
const withCSS = require('@zeit/next-css')
module.exports = withCSS({
webpack: config => {
config.module.rules.push({
test: /\.(eot|woff|woff2|ttf|svg|png|jpg|gif)$/,
use: {
loader: 'url-loader',
options: {
limit: 100000,
name: '[name].[ext]'
}
}
})
return config
}
})
现在.json:
{
"version": 2,
"builds": [
{"src": "package.json", "use": "@now/next"},
{ "src": "server.js", "use": "@now/node" }
]
}
package.json 的脚本部分:
"scripts": {
"now-build": "next build",
"dev": "node server.js",
"build": "next build",
"start": "cross-env NODE_ENV=production node server.js"
}
我得到的错误:server.js:
Error: No serverless pages were built. https://err.sh/zeit/now-builders/now-next-no-serverless-pages-built
at Object.exports.build (/tmp/26a0d565/.build-utils/.builder/node_modules/@now/next/dist/index.js:275:19)
at <anonymous>
包.json:
UnhandledPromiseRejectionWarning: TypeError: Data must be a string or a buffer
at Hash.update (crypto.js:99:16)
at ids.forEach.id (/tmp/2d245f3b/node_modules/next/dist/build/webpack/plugins/hashed-chunk-ids-plugin.js:24:41)
如果我按照无服务器错误链接上的说明进行操作,我仍然会收到相同的错误。
const withCSS = require('@zeit/next-css')
module.exports = withCSS({
target: 'serverless',
webpack: config => {
config.module.rules.push({
test: /\.(eot|woff|woff2|ttf|svg|png|jpg|gif)$/,
use: {
loader: 'url-loader',
options: {
limit: 100000,
name: '[name].[ext]'
}
}
})
return config
}
})
如果我删除 now.json 然后部署它只是在页面上列出文件夹。互联网上有很多关于这些错误的信息,但我无法解决它