-
Notifications
You must be signed in to change notification settings - Fork 380
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Bug]: 当使用仓库镜像时,modern 命令报错:package @modern-js/codesmith-global@latest not found in registry #6879
Comments
你的意思是加上了 你可以试试在这个 npm 源下,直接执行 |
@StephenPCG 使用 @modern-js/create 的时候加一下 --registry 参数,指向你们自己的 registry |
@caohuilin 正是由于用了我们自己的 registry 才导致的错误,见我前面那条回复,我跟进了一下 codesmith 的代码,发现 PS,我看 ![]() |
@StephenPCG 看起来是你们 nexus oss 的问题了,正常应该存在 version 字段的 |
我搜了一下 commonjs registry specification,package version url 中确实提到了返回的内容中应当有 这个问题就不打扰你们了,我回头如果有其他发现的话再来补充信息。目前这个问题对我的主要影响是 |
我刚才找了一下,最新的 npm public registry 的 API:https://github.com/npm/registry/blob/main/docs/REGISTRY-API.md 这里面似乎没有提及 package version url 的 response 内容,只提到了 package root url 的 response,即 Package Metadata ,这里面似乎确实没有提到 我看了一下
对于 package root url,我看了下,我们自己的 registry 返回的内容跟 npmjs 的一致,这里面都没有 ![]() |
@StephenPCG 不一样吧,我理解路径上面有 latest 的话应该有 version 字段的,路径上面没有的话应该没有 version 字段 |
@caohuilin 对,是两个不同的 url。 我一时也没有找到 package version url 的比较权威、比较新的 spec 文档。对于 version url,我试了一下,npmjs、淘宝的镜像,返回的内容是一样的,nexus oss 返回的就不同。而 nexus oss 对于不同的包返回的内容似乎也不同,随便试了几个包,发现对于没有 scope 的包似乎返回的内容都带 version 字段,对于有 scope 的包,返回的内容好像都不带 version 字段(不过因为是手动试的,所以也不确定这是不是规律)。我在网上搜了一圈也没有找到相关的文章。 不知道能否改一下 |
嗯嗯 可以的,我去改一下 |
@StephenPCG web-infra-dev/codesmith#175 看看这样 ok 吗? |
@caohuilin 目测应该没问题。不过我有没有什么办法可以本地测试一下的? |
不好测试,我这里是直接拿的 npx 的版本,得去 npx 的 cache 目录去修改源码 |
那就不用测了吧 😂 |
@StephenPCG 我发了一个 next 版本,你试试 npx @modern-js/create@next my-app --dist-tag next |
我也是使用 nexus 搭建,并使用了认证,但是 create 项目不会带默认 .npmrc 的认证 token |
我试了一下,还是不行: $ npx @modern-js/create@next my-app --dist-tag next
Need to install the following packages:
@modern-js/[email protected]
Ok to proceed? (y)
🏃 Load Generator.../Users/stephen/.npm/_npx/dc0c274888ad1976/node_modules/@modern-js/create/dist/index.js:45353
throw new Error(`package ${pkgName}@${pkgVersion} not found in registry`);
^
Error: package @modern-js/codesmith-global@latest not found in registry
at /Users/stephen/.npm/_npx/dc0c274888ad1976/node_modules/@modern-js/create/dist/index.js:45353:15
at Generator.next (<anonymous>)
at fulfilled (/Users/stephen/.npm/_npx/dc0c274888ad1976/node_modules/@modern-js/create/dist/index.js:59:24)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
Node.js v20.18.3
# 将上述报错中的 @modern-js/create 路径找到 package.json,查看 version 确实是 next 版本,但依赖的 codesmith 仍然是2.6.5
$ grep -E '(version|codesmith)' /Users/stephen/.npm/_npx/dc0c274888ad1976/node_modules/@modern-js/create/package.json
"version": "0.0.0-next-20250224105011",
"@modern-js/codesmith": "2.6.5",
"@modern-js/codesmith-utils": "2.6.5", |
根据我最前面贴的 看起来 不过我比较好奇,为什么明明有 |
@StephenPCG 那就等一下周四发版吧,这里优先用 url 是因为命令返回的时间比较慢,做了个优化 |
本地 .npmrc $ cat ~/.npmrc
#registry=https://registry.npmmirror.com
registry=https://nexus.域名.com/repository/npm
//nexus.域名.com/repository/npm-distribution/:_authToken=打码
//nexus.域名.com/repository/npm/:_authToken=打码
//nexus.域名.com/repository/:_authToken=打码
//registry.npmjs.org/:_authToken=打码 @caohuilin 这个 401 问题是否也处理一下? |
@lanmingle 这次发版之后应该这个问题会自动修复 |
版本信息
问题详情
我们公司内部搭建了 npmjs 的镜像(使用 nexus oss 搭建),我在本地的
~/.npmrc
中如下配置:该镜像已使用了数年,之前没有碰到过问题。这两天我们打算开始用 modern.js,碰到了问题。
首先是创建项目,
pnpm dlx @modern-js/create@latest
,会报如下错误:将
npmrc
中registry
一行注释掉之后重新运行上述命令,可以成功。恢复npmrc
文件,日常所有操作都正常。但运行modern new
等命令时,仍然会报上述错误。不知道是不是
downloadPackage
中下载包的方式有问题,导致 nexus 没有去上游检查文件,而是直接返回了 404(这是我根据现象猜测的,希望没有把问题带偏)?复现链接
无
复现步骤
见问题详情
The text was updated successfully, but these errors were encountered: