My understanding is that "perf_hooks" is a component of Node.js. However, when I run tests with npm test
, it fails for me and shows the following error (some file names have been altered):
Error: ENOENT: no such file or directory, open 'perf_hooks'
at Object.openSync (fs.js:465:3)
at Object.readFileSync (fs.js:368:35)
at SandboxedModule._getCompileInfo (node_modules/sandboxed-module/lib/sandboxed_module.js:265:20)
at SandboxedModule._compile (node_modules/sandboxed-module/lib/sandboxed_module.js:245:22)
at createInnerSandboxedModule (node_modules/sandboxed-module/lib/sandboxed_module.js:183:23)
at SandboxedModule.RecursiveRequireProxy (node_modules/sandboxed-module/lib/sandboxed_module.js:214:27)
at /Users/asmirnov/Documents/blabla2.js:51:12
at Object.<anonymous> (lib/profiler.js:53:3)
at SandboxedModule._compile (node_modules/sandboxed-module/lib/sandboxed_module.js:251:19)
at createInnerSandboxedModule (node_modules/sandboxed-module/lib/sandboxed_module.js:183:23)
at SandboxedModule.RecursiveRequireProxy (node_modules/sandboxed-module/lib/sandboxed_module.js:214:27)
at Object.<anonymous> (lib/blabla1.js:29:20)
at SandboxedModule._compile (node_modules/sandboxed-module/lib/sandboxed_module.js:251:19)
at createInnerSandboxedModule (node_modules/sandboxed-module/lib/sandboxed_module.js:183:23)
at SandboxedModule.RecursiveRequireProxy (node_modules/sandboxed-module/lib/sandboxed_module.js:214:27)
at SandboxedModule.requireInterceptor (node_modules/sandboxed-module/lib/sandboxed_module.js:227:9)
at Context.<anonymous> (test/blabla1.js:73:22)
at processImmediate (internal/timers.js:458:21)
The snippet below is from the file (lib/profiler.js
) where "perf_hooks" is utilized:
const {performance, PerformanceObserver} = (function()
{
try
{
if (window && typeof window.performance == "undefined")
throw new TypeError();
return window;
}
catch (e)
{
return require("perf_hooks");
}
})();
What could possibly be causing this issue? Interestingly, in some instances (npm run ..
) it behaves as expected. Any insights or recommendations would be greatly appreciated.
PS. My Node version is relatively recent:
> node --version
v14.8.0