我的代码在localhost上运行正常:
import fs from 'fs'
import path from 'path'
export default function createUserDir (tokenSignature: string) {
const pathToMakeDir = path.join(process.cwd(), 'notes', tokenSignature);
fs.mkdirSync(pathToMakeDir, { recursive: true });
}
正如你所看到的,我已经使用了recursive flag。
错误如下:
2022-11-15T19:32:34.119Z 145c46ab-416c-4f5c-b881-80b9c623a5ac ERROR Error: ENOENT: no such file or directory, mkdir '/var/task/notes/jFlqLkrmIPOEnaiExiUN3ohlmJlH_GN2OD36fiQ9a2A'
at Object.mkdirSync (node:fs:1349:3)
at createUserDir (/var/task/.next/server/chunks/133.js:252:45)
at getServerSideProps (/var/task/.next/server/pages/index.js:93:76)
at Object.renderToHTML (/var/task/node_modules/next/dist/server/render.js:506:26)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async doRender (/var/task/node_modules/next/dist/server/base-server.js:701:34)
at async cacheEntry.responseCache.get.isManualRevalidate.isManualRevalidate (/var/task/node_modules/next/dist/server/base-server.js:806:28)
at async /var/task/node_modules/next/dist/server/response-cache/index.js:80:36 {
errno: -2,
syscall: 'mkdir',
path: '/var/task/notes/jFlqLkrmIPOEnaiExiUN3ohlmJlH_GN2OD36fiQ9a2A',
page: '/'
}
RequestId: 145c46ab-416c-4f5c-b881-80b9c623a5ac Error: Runtime exited with error: exit status 1
Runtime.ExitError
这个错误是没有意义的,因为我已经在使用这个标志了。
我使用的是Next版本13.0.3,Vercel运行的是Node 16.x
1条答案
按热度按时间c0vxltue1#
我在尝试调用
fs
方法时遇到了类似的问题。尝试将output: 'standalone'
添加到next.config.js
在其他地方搜索时,建议添加
nftTracing: true
,但它似乎已被弃用。如果以上方法不起作用,请尝试检出this long GH issue