Example "aot-module" fails with [ERR_MODULE_NOT_FOUND]: Cannot find package 'node-api-dotnet'
还没有人认领这个 Issue。
评估
- 难度
- 2/5
- 预计耗时
- 1-3 小时
- 新手友好度
- 45/100
- Issue 类型
- 缺陷
- 描述清晰度
- 基本清楚
- 活跃度
- 停滞
- 技术栈
- csharp, javascript, node.js
- 领域
- build-system
调研方向
首先在报告的提交上运行 examples/aot-module/README.md 中的命令,并检查 bin/aot-module.js,尤其是其中对 node-api-dotnet 的导入。文档中的命令能够成功运行并输出 "Hello .NET AOT!",且无需手动替换导入时,该 issue 即完成。
由索引模型根据 Issue 内容生成。
描述
To repro, I'm on main branch commit 11c5a48.
I'm following the instructions at examples/aot-module/README.md:
cd examples\aot-module
dotnet pack ../..
dotnet publish
node example.js
And I get this error:
node:internal/modules/package_json_reader:268
throw new ERR_MODULE_NOT_FOUND(packageName, fileURLToPath(base), null);
^
Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'node-api-dotnet' imported from D:\node-api-dotnet\examples\aot-module\bin\aot-module.js
at Object.getPackageJSONURL (node:internal/modules/package_json_reader:268:9)
at packageResolve (node:internal/modules/esm/resolve:768:81)
at moduleResolve (node:internal/modules/esm/resolve:854:18)
at defaultResolve (node:internal/modules/esm/resolve:984:11)
at ModuleLoader.defaultResolve (node:internal/modules/esm/loader:685:12)
at #cachedDefaultResolve (node:internal/modules/esm/loader:634:25)
at ModuleLoader.resolve (node:internal/modules/esm/loader:617:38)
at ModuleLoader.getModuleJobForImport (node:internal/modules/esm/loader:273:38)
at ModuleJob._link (node:internal/modules/esm/module_job:135:49) {
code: 'ERR_MODULE_NOT_FOUND'
}
Node.js v22.14.0
I found I could fix this by making this change in bin/aot-module.js:
// Removed this line:
//import dotnet from 'node-api-dotnet/net8.0';
// Added this line:
const dotnet = undefined;
And then it works fine:
Hello .NET AOT!
- 主要语言
- C#
- 星标
- 783
- 派生
- 80
- PR 合并指标
- 30 天内没有已合并 PR
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
microsoft/node-api-dotnet 的其他 Issue
-
难度 1/5 1-3 小时 新手友好度 88/100
microsoft/node-api-dotnet#484 ·
-
难度 2/5 1-3 小时 新手友好度 82/100
microsoft/node-api-dotnet#481 ·
-
难度 5/5 一周以上 新手友好度 35/100
microsoft/node-api-dotnet#486 · 1 条评论 ·
-
难度 5/5 一周以上 新手友好度 35/100
microsoft/node-api-dotnet#483 · 1 条评论 · 1 个 reaction ·
-
难度 4/5 3-5 天 新手友好度 45/100
microsoft/node-api-dotnet#479 ·
查看 microsoft/node-api-dotnet 的全部 Issue
相似的 Issue
-
untriaged
难度 1/5 1 小时以内 新手友好度 88/100
dotnet/dotnet-api-docs#13095 ·
-
area-deployment area-integrations triage:bot-seen
难度 2/5 半天 新手友好度 86/100
-
type/automation type/tech-debt
难度 2/5 1-3 小时 新手友好度 84/100
-
bug
难度 1/5 1 小时以内 新手友好度 90/100
newrelic/newrelic-dotnet-agent#3850 · 1 条评论 ·
-
难度 2/5 1-3 小时 新手友好度 88/100
LuckyPennySoftware/AutoMapper#4660 ·