I 'm migrating my cdk stack to sst, and I have an ...
# help
u
I 'm migrating my cdk stack to sst, and I have an error message : ENOENT: no such file or directory, open '<path>/.build/lib/<myfile>.sql' my file is in a folder and is used to build a query in kinesis data analytics. In cdk, I loaded this file with readFileSync
Copy code
applicationCode: fs.readFileSync(
        path.join(__dirname, '.', '<myfile>.sql'),
        'utf8'
)
I read there was a copyFiles available for Function but how to do it without Function ?
j
I’ll let @Frank add more details to this but what’s happening is that the transpiled code is copied to the
.build
directory. So the
__dirname
here is pointing to that. For now you can workaround this by using a relative path but I think we need a proper solution for this.
f
I see. @Uncharted let me play around with it and see what we can do here.
Hey @Uncharted, sorry about the delay. I’m sure u got it working already. The easiest way around this is to use
process.cwd()
instead of `__dirname`:
Copy code
path.join(process.cwd(), "path/to/<myfile>.sql")
process.cwd()
points to the root of your SST app, ie. where your
sst.json
sits
Let me know if this works for you.
u
Hi Frank Thanks for the answer I will try it when I'll have time and let you know if it works