My folder structure
Node (root directory)
-data
-123.mp4
-src
-test.ts
-build
-test.js
My ts. file in src folder,
import { createReadStream, createWriteStream } from 'fs';
const readStram = createReadStream('../data/123.mp4')
const writeStream = createWriteStream('../data/copy.mp4')
compiled to build folder,
import { createReadStream, createWriteStream } from 'fs';
const readStram = createReadStream('../data/123.mp4');
const writeStream = createWriteStream('../data/copy.mp4');
I got an error, that said no such file or directory, what should I do to keep js file has the right path to load 123.mp4?
trying to use the path module, but there is another error mentioned __dirname can't use in ES module.
my ts.config
{
"include": ["src/**"],
"exclude": ["node_modules"],
"compilerOptions": {
"target": "ES2016" /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */,
"module": "Node16" /* Specify what module code is generated. */,
"rootDir": "./src" /* Specify the root folder within your source files. */,
"moduleResolution": "Node16" /* Specify how TypeScript looks up a file from a given module specifier. */,
"outDir": "./build" /* Specify an output folder for all emitted files. */,
"forceConsistentCasingInFileNames": true /* Ensure that casing is correct in imports. */,
"strict": true /* Enable all strict type-checking options. */,
"skipLibCheck": true /* Skip type checking all .d.ts files. */
}
}