@@ -3,6 +3,7 @@ const clean = require('semver/functions/clean')
33const fs = require ( 'node:fs/promises' )
44const path = require ( 'node:path' )
55const { log } = require ( 'proc-log' )
6+ const moduleBuiltin = require ( 'node:module' )
67
78/**
89 * @type {import('hosted-git-info') }
@@ -144,7 +145,7 @@ const normalize = async (pkg, { strict, steps, root, changes, allowLegacyCase })
144145 const pkgId = `${ data . name ?? '' } @${ data . version ?? '' } `
145146
146147 // name and version are load bearing so we have to clean them up first
147- if ( steps . includes ( 'fixNameField' ) || steps . includes ( 'normalizeData' ) ) {
148+ if ( steps . includes ( 'fixName' ) || steps . includes ( ' fixNameField') || steps . includes ( 'normalizeData' ) ) {
148149 if ( ! data . name && ! strict ) {
149150 changes ?. push ( 'Missing "name" field was set to an empty string' )
150151 data . name = ''
@@ -170,6 +171,13 @@ const normalize = async (pkg, { strict, steps, root, changes, allowLegacyCase })
170171 }
171172 }
172173
174+ if ( steps . includes ( 'fixName' ) ) {
175+ // Check for conflicts with builtin modules
176+ if ( moduleBuiltin . builtinModules . includes ( data . name ) ) {
177+ log . warn ( 'package-json' , pkgId , `Package name "${ data . name } " conflicts with a Node.js built-in module name` )
178+ }
179+ }
180+
173181 if ( steps . includes ( 'fixVersionField' ) || steps . includes ( 'normalizeData' ) ) {
174182 // allow "loose" semver 1.0 versions in non-strict mode
175183 // enforce strict semver 2.0 compliance in strict mode
0 commit comments