Skip to content

Commit

Permalink
fix: lazy load validate npm package name on error message (#7347)
Browse files Browse the repository at this point in the history
![image](https://github.com/npm/cli/assets/12551007/0a573258-858d-406c-bbf5-926f62fde964)

This package takes 5ms to load even if we didn't use it.
  • Loading branch information
H4ad committed Apr 9, 2024
1 parent 81be28d commit 5fc0f9d
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/utils/error-message.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
const { format } = require('util')
const { resolve } = require('path')
const nameValidator = require('validate-npm-package-name')
const { redactLog: replaceInfo } = require('@npmcli/redact')
const { report } = require('./explain-eresolve.js')
const log = require('./log-shim')
Expand Down Expand Up @@ -215,6 +214,7 @@ const errorMessage = (er, npm) => {
detail.push(['404', ''])
detail.push(['404', '', `'${replaceInfo(er.pkgid)}' is not in this registry.`])

const nameValidator = require('validate-npm-package-name')
const valResult = nameValidator(pkg)

if (!valResult.validForNewPackages) {
Expand Down

0 comments on commit 5fc0f9d

Please sign in to comment.