Unable to write files during build

12:59:30.925 > ls && node generate-content.js && astro build
12:59:30.925
12:59:30.939 README.md
12:59:30.939 assets
12:59:30.939 astro.config.mjs
12:59:30.940 generate-content.js
12:59:30.940 node_modules
12:59:30.940 package.json
12:59:30.940 pnpm-lock.yaml
12:59:30.940 public
12:59:30.940 src
12:59:30.940 svelte.config.js
12:59:30.941 tailwind.config.cjs
12:59:30.941 tsconfig.json
12:59:33.662 node:fs:601
12:59:33.662 handleErrorFromBinding(ctx);
12:59:33.663 ^
12:59:33.664 Error: ENOENT: no such file or directory, open 'src/content/courses/AAH-1010.json'
12:59:33.664 at Object.openSync (node:fs:601:3)
12:59:33.664 at writeFileSync (node:fs:2249:35)
12:59:33.664 at file:///opt/buildhome/repo/generate-content.js:71:3 {
12:59:33.664 errno: -2,
12:59:33.666 syscall: 'open',
12:59:33.666 code: 'ENOENT',
12:59:33.666 path: 'src/content/courses/AAH-1010.json'
12:59:33.666 }
12:59:30.925 > ls && node generate-content.js && astro build
12:59:30.925
12:59:30.939 README.md
12:59:30.939 assets
12:59:30.939 astro.config.mjs
12:59:30.940 generate-content.js
12:59:30.940 node_modules
12:59:30.940 package.json
12:59:30.940 pnpm-lock.yaml
12:59:30.940 public
12:59:30.940 src
12:59:30.940 svelte.config.js
12:59:30.941 tailwind.config.cjs
12:59:30.941 tsconfig.json
12:59:33.662 node:fs:601
12:59:33.662 handleErrorFromBinding(ctx);
12:59:33.663 ^
12:59:33.664 Error: ENOENT: no such file or directory, open 'src/content/courses/AAH-1010.json'
12:59:33.664 at Object.openSync (node:fs:601:3)
12:59:33.664 at writeFileSync (node:fs:2249:35)
12:59:33.664 at file:///opt/buildhome/repo/generate-content.js:71:3 {
12:59:33.664 errno: -2,
12:59:33.666 syscall: 'open',
12:59:33.666 code: 'ENOENT',
12:59:33.666 path: 'src/content/courses/AAH-1010.json'
12:59:33.666 }
for (const page in pages){
const obj = pages[page]
writeFileSync(join('.','src','content','courses',`${obj.department}-${obj.number}.json`),JSON.stringify(obj))
}
for (const page in pages){
const obj = pages[page]
writeFileSync(join('.','src','content','courses',`${obj.department}-${obj.number}.json`),JSON.stringify(obj))
}
1 Reply
i40west
i40west11mo ago
Looks like the directory you're trying to create the file in doesn't exist.