Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

`docsify` fails under yarn pnp strict mode due to missing `ansi-colors` dependency

未关闭
#191 2 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
1/5
预计耗时
1 小时以内
新手友好度
55/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
停滞
技术栈
javascript, nodejs
领域
cli, tooling

调研方向

先从 lib/commands/init.js 开始,确认直接 require ansi-colors,然后检查 package.json 和现有的 package-lock.json 版本。添加缺失的依赖项,并在 Yarn Plug'n'Play 严格模式下运行 yarn run docsify;完成的标准是该命令在没有未声明依赖项错误的情况下启动。

由索引模型根据 Issue 内容生成。

描述

Yarn (v2/3) by default operates in a strict Plug'n'Play mode which does not allow directly loading indirect dependencies.

lib/commands/init.js directly requires ansi-colors, but it's not listed in package.json.

yarn run docsify, therefore, fails (even if docsify-cli is correctly registered in package.json).

Adding "ansi-colors": "^4.1.1" to dependencies should be enough (I chose that version because it's what's already in package-lock.json from an indirect dependency).

$ yarn run docsify
/Users/tlilley/projects/veatech/sbx/smithy/.pnp.cjs:11796
    throw firstError;
    ^

Error: docsify-cli tried to access ansi-colors, but it isn't declared in its dependencies; this makes the require call ambiguous and unsound.

Required package: ansi-colors
Required by: docsify-cli@npm:4.4.4 (via /Users/tlilley/projects/veatech/sbx/smithy/.yarn/cache/docsify-cli-npm-4.4.4-3d7dbcc799-2f72ff07d0.zip/node_modules/docsify-cli/lib/commands/)

Require stack:
- /Users/tlilley/projects/veatech/sbx/smithy/.yarn/cache/docsify-cli-npm-4.4.4-3d7dbcc799-2f72ff07d0.zip/node_modules/docsify-cli/lib/commands/init.js
- /Users/tlilley/projects/veatech/sbx/smithy/.yarn/cache/docsify-cli-npm-4.4.4-3d7dbcc799-2f72ff07d0.zip/node_modules/docsify-cli/lib/index.js
- /Users/tlilley/projects/veatech/sbx/smithy/.yarn/cache/docsify-cli-npm-4.4.4-3d7dbcc799-2f72ff07d0.zip/node_modules/docsify-cli/bin/docsify
    at require$$0.Module._resolveFilename (/Users/tlilley/projects/veatech/sbx/smithy/.pnp.cjs:11795:13)
    at require$$0.Module._load (/Users/tlilley/projects/veatech/sbx/smithy/.pnp.cjs:11645:42)
    at Module.require (node:internal/modules/cjs/loader:1157:19)
    at require (node:internal/modules/helpers:119:18)
    at Object.<anonymous> (/Users/tlilley/projects/veatech/sbx/smithy/.yarn/cache/docsify-cli-npm-4.4.4-3d7dbcc799-2f72ff07d0.zip/node_modules/docsify-cli/lib/commands/init.js:10:16)
    at Module._compile (node:internal/modules/cjs/loader:1275:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1329:10)
    at require$$0.Module._extensions..js (/Users/tlilley/projects/veatech/sbx/smithy/.pnp.cjs:11839:33)
    at Module.load (node:internal/modules/cjs/loader:1133:32)
    at require$$0.Module._load (/Users/tlilley/projects/veatech/sbx/smithy/.pnp.cjs:11676:14)

Node.js v19.8.1
主要语言
JavaScript
星标
781
派生
166
PR 合并指标
30 天内没有已合并 PR

环境准备

  • 没有 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 阅读贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

docsifyjs/docsify-cli 的其他 Issue

查看 docsifyjs/docsify-cli 的全部 Issue

相似的 Issue

更多 JavaScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。