如何求解“错误:软件包子路口.."使用茉莉花-TS?

发布于 2025-02-11 08:16:41 字数 937 浏览 1 评论 0原文

我正在使用茉莉花和茉莉花-TS运行一个nodejs项目,

当我尝试运行测试时,我会遇到这些错误

错误:软件包subpath'./lib/command'未通过“导出”定义 D:\ projects -abzo \ project 2 \ node_modules \ jasmine \ package.json 在New Nodeerror(节点:内部/错误:372:5) 在therexportsnotfound(节点:内部/模块/ESM/Resolve:472:9) 在Package Exportsresolve(节点:内部/模块/ESM/Resolve:753:3) 在ResolveExports(节点:内部/模块/CJS/LOADER:482:36) at function.module._findpath(节点:内部/模块/CJS/LOADER:522:31) 在function.module._resolvefilename(节点:内部/模块/cjs/loader:919:27) 在function.module._load(节点:内部/模块/CJS/LOADER:778:27) 在模块上。 AT Require(节点:内部/模块/CJS/助手:102:18) 在对象。 (d:\ projects -abzo \ project 2 \ node_modules \ jasmine -ts \ src \ index.ts:143:17)

我试图将我的TS节点版本降级到8.10.2,就像在此stackoverflow问题中一样, https://stackoverflow.com/questions/65335931/jasmine-ts-ths-ths-ths-throwing-an-error-about-cage-subpath"> jasmine-ts抛出有关软件包subpath的错误,但仍未解决。

我在package.json中的脚本是“ test”:“茉莉花-TS”

I'm running a nodejs project with jasmine and jasmine-ts

i get these errors when i try to run my tests

Error: Package subpath './lib/command' is not defined by "exports" in
D:\Projects - Abzo\Project 2\node_modules\jasmine\package.json
at new NodeError (node:internal/errors:372:5)
at throwExportsNotFound (node:internal/modules/esm/resolve:472:9)
at packageExportsResolve (node:internal/modules/esm/resolve:753:3)
at resolveExports (node:internal/modules/cjs/loader:482:36)
at Function.Module._findPath (node:internal/modules/cjs/loader:522:31)
at Function.Module._resolveFilename (node:internal/modules/cjs/loader:919:27)
at Function.Module._load (node:internal/modules/cjs/loader:778:27)
at Module.require (node:internal/modules/cjs/loader:1005:19)
at require (node:internal/modules/cjs/helpers:102:18)
at Object. (D:\Projects - Abzo\Project 2\node_modules\jasmine-ts\src\index.ts:143:17)

I tried to downgrade my ts-node version to 8.10.2 like in this stackoverflow question Jasmine-ts throwing an error about package subpath but still unsolved.

My script in package.json is "test":"jasmine-ts"

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

若水微香 2025-02-18 08:16:41

问题在于enfort jasmine package.json的属性:

Jasmine仅导出Jasmine.js file,

"exports": "./lib/jasmine.js"

但在中Jasmine-ts 代码需要命令文件(围绕第164行),

const Command = require("jasmine/lib/command");

现在此文件不是导出的一部分,因此它会引发错误:

错误:软件包subpath'./lib/command'未通过“ exports”定义

来修复此茉莉花需要导出jasmine-ts使用的命令文件。
我在茉莉package.json中测试了以下更改,并解决了问题:

"exports": {
  ".": "./lib/jasmine.js",
  "./lib/command": "./lib/command.js"
}

更改Jasmine package.json不是一个很好的解决方案,但目前这是唯一的解决方案我的头顶。
我将尝试向茉莉花GitHub存储库打开问题。

The problem is in the in the exports property of jasmine package.json:

Jasmine exports only the jasmine.js file

"exports": "./lib/jasmine.js"

But in the jasmine-ts code there is a require to command file (around row 164)

const Command = require("jasmine/lib/command");

Now this file is not part of the exports so it throws the error:

Error: Package subpath './lib/command' is not defined by "exports"

To fix this jasmine need to export also the command file used by jasmine-ts.
I tested with the following changes in jasmine package.json and solve the problem:

"exports": {
  ".": "./lib/jasmine.js",
  "./lib/command": "./lib/command.js"
}

Changing the jasmine package.json is not a great solution but for now this is the only solution on top of my mind.
I'll try open an issue to jasmine github repository.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文