You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
TypeError [ERR_INVALID_CALLBACK]: Callback must be a function. Received undefined
at maybeCallback (node:fs:177:3)
at Object.exists (node:fs:260:3)
at Object.<anonymous> (/Users/lancegliser/Projects/lancegliser/connect-dynamodb-v2-dependency/test/test.js:9:17)
at Module._compile (node:internal/modules/cjs/loader:1101:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
at Module.load (node:internal/modules/cjs/loader:981:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
at ModuleWrap.<anonymous> (node:internal/modules/esm/translators:190:29)
at ModuleJob.run (node:internal/modules/esm/module_job:185:25)
at async Promise.all (index 0)
at async ESMLoader.import (node:internal/modules/esm/loader:281:24)
at async importModuleDynamicallyWrapper (node:internal/vm/module:437:15)
at async formattedImport (/Users/lancegliser/Projects/lancegliser/connect-dynamodb-v2-dependency/node_modules/mocha/lib/nodejs/esm-utils.js:7:14)
at async Object.exports.requireOrImport (/Users/lancegliser/Projects/lancegliser/connect-dynamodb-v2-dependency/node_modules/mocha/lib/nodejs/esm-utils.js:38:28)
at async Object.exports.loadFilesAsync (/Users/lancegliser/Projects/lancegliser/connect-dynamodb-v2-dependency/node_modules/mocha/lib/nodejs/esm-utils.js:91:20)
at async singleRun (/Users/lancegliser/Projects/lancegliser/connect-dynamodb-v2-dependency/node_modules/mocha/lib/cli/run-helpers.js:125:3)
at async Object.exports.handler (/Users/lancegliser/Projects/lancegliser/connect-dynamodb-v2-dependency/node_modules/mocha/lib/cli/run.js:370:5)
test/test.js:9:17 is:
varfs=require('fs'),// Other stuffvarconfig=fs.exists('./aws-config.json')&&fs.readFileSync('./aws-config.json');
The definition of fs.exists reads:
deprecated export function exists( path: PathLike, callback: (exists: boolean) => void): void
Test whether or not the given path exists by checking with the file system. Then call the callback argument with either true or false:
import { exists } from 'fs';
exists('/etc/passwd', (e) => {
console.log(e ? 'it exists' : 'no passwd!');
});
The parameters for this callback are not consistent with other Node.js callbacks. Normally, the first parameter to a Node.js callback is an errparameter, optionally followed by other parameters. The fs.exists() callback has only one boolean parameter. This is one reason fs.access() is recommended instead of fs.exists().
Using fs.exists() to check for the existence of a file before callingfs.open(), fs.readFile() or fs.writeFile() is not recommended. > Doing so introduces a race condition, since other processes may change the file's state between the two calls. Instead, user code should open/read/write the file directly and handle the error raised if the file does not exist.
If I update the test config file read to the follow it works:
On the
master
branch, using the commands README:I run into this error:
test/test.js:9:17 is:
The definition of
fs.exists
reads:If I update the test config file read to the follow it works:
Not sure I care to fix it, as I'm looking a different configuration in #76 but thought I'd document the issue and solution.
The text was updated successfully, but these errors were encountered: