MCPcopy Index your code
hub / github.com/nodejs/node / warnTypelessPackageJsonFile

Function warnTypelessPackageJsonFile

lib/internal/modules/esm/get_format.js:145–156  ·  view source on GitHub ↗
(pjsonPath, url)

Source from the content-addressed store, hash-verified

143
144let typelessPackageJsonFilesWarnedAbout;
145function warnTypelessPackageJsonFile(pjsonPath, url) {
146 typelessPackageJsonFilesWarnedAbout ??= new SafeSet();
147 if (!underNodeModules(url) && !typelessPackageJsonFilesWarnedAbout.has(pjsonPath)) {
148 const warning = `Module type of ${url} is not specified and it doesn't parse as CommonJS.\n` +
149 'Reparsing as ES module because module syntax was detected. This incurs a performance overhead.\n' +
150 `To eliminate this warning, add "type": "module" to ${pjsonPath}.`;
151 process.emitWarning(warning, {
152 code: 'MODULE_TYPELESS_PACKAGE_JSON',
153 });
154 typelessPackageJsonFilesWarnedAbout.add(pjsonPath);
155 }
156}
157
158/**
159 * @param {URL} url

Callers 1

Calls 3

underNodeModulesFunction · 0.85
hasMethod · 0.65
addMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…