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
When the .npmrc file contains a comment on the same line as a registry setting, the nuxi module add command fails.
.npmrc:
registry=https://registry.npmjs.org # test comment
Steps to reproduce:
$ git clone https://github.com/odan-sandbox/nuxt-module-npmrc-comment-error-repro
$ cd nuxt-module-npmrc-comment-error-repro
$ npm i
$ npx nuxi module add pinia
[2:16:01] ERROR [GET] "https://registry.npmjs.org # test comment/@pinia/nuxt": <no response> Failed to parse URL from https://registry.npmjs.org # test comment/@pinia/nuxt
at async $fetchRaw2 (node_modules/nuxi/dist/shared/nuxi.BzZJv2UC.mjs:371:14)
at async $fetch2 (node_modules/nuxi/dist/shared/nuxi.BzZJv2UC.mjs:417:15)
at async resolveModule (node_modules/nuxi/dist/chunks/add2.mjs:315:22)
at async Promise.all (index 0)
at async Object.setup (node_modules/nuxi/dist/chunks/add2.mjs:150:34)
at async runCommand$1 (node_modules/nuxi/dist/shared/nuxi.BlFGnQYG.mjs:1739:5)
at async runCommand$1 (node_modules/nuxi/dist/shared/nuxi.BlFGnQYG.mjs:1758:11)
at async runCommand$1 (node_modules/nuxi/dist/shared/nuxi.BlFGnQYG.mjs:1758:11)
at async runMain$1 (node_modules/nuxi/dist/shared/nuxi.BlFGnQYG.mjs:1896:7)
[cause]: Failed to parse URL from https://registry.npmjs.org # test comment/@pinia/nuxt
at node:internal/deps/undici/undici:13510:13
at async $fetchRaw2 (node_modules/nuxi/dist/shared/nuxi.BzZJv2UC.mjs:359:26)
[cause]: Invalid URL
at new URL (node:internal/url:818:25)
at new Request (node:internal/deps/undici/undici:9586:25)
at fetch (node:internal/deps/undici/undici:10315:25)
at fetch (node:internal/deps/undici/undici:13508:10)
at fetch (node:internal/bootstrap/web/exposed-window-or-worker:75:12)
at node_modules/nuxi/dist/shared/nuxi.BzZJv2UC.mjs:451:58
at $fetchRaw2 (node_modules/nuxi/dist/shared/nuxi.BzZJv2UC.mjs:359:32)
at onError (node_modules/nuxi/dist/shared/nuxi.BzZJv2UC.mjs:280:16)
at $fetchRaw2 (node_modules/nuxi/dist/shared/nuxi.BzZJv2UC.mjs:371:20)
at async $fetch2 (node_modules/nuxi/dist/shared/nuxi.BzZJv2UC.mjs:417:15)
[2:16:01] ERROR [GET] "https://registry.npmjs.org # test comment/@pinia/nuxt": <no response> Failed to parse URL from https://registry.npmjs.org # test comment/@pinia/nuxt
Expected behavior:
The command should ignore comments in .npmrc and proceed with the module installation.
Cause of the issue
It is likely that the .npmrc file is not correctly removing comments when parsing the registry setting.
There is a bug in the regular expression used in the getRegistryFromFile function.
I am interested in resolving this issue. If you can suggest a preferred solution, I would like to create a pull request to fix this bug.
The text was updated successfully, but these errors were encountered:
odanado
changed the title
When .npmrc contains comments, the nuxi module add command fails.
When .npmrc contains comments, the nuxi module add command fails.
May 15, 2025
Thank you for the suggestion.
Since modifying unjs/nypm might be a bit too time-consuming at this point, I would like to proceed with directly using confbox to handle .npmrc parsing in nuxi.
I will proceed with this approach and create a pull request. Feel free to review it.
When the
.npmrc
file contains a comment on the same line as aregistry
setting, thenuxi module add
command fails..npmrc
:Steps to reproduce:
Expected behavior:
The command should ignore comments in
.npmrc
and proceed with the module installation.Cause of the issue
It is likely that the
.npmrc
file is not correctly removing comments when parsing theregistry
setting.There is a bug in the regular expression used in the
getRegistryFromFile
function.cli/packages/nuxi/src/commands/module/add.ts
Line 402 in 54e9850
Possible solutions:
.npmrc
.I am interested in resolving this issue. If you can suggest a preferred solution, I would like to create a pull request to fix this bug.
The text was updated successfully, but these errors were encountered: