如何求解“错误:软件包子路口.."使用茉莉花-TS?
我正在使用茉莉花和茉莉花-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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
问题在于enfort jasmine package.json的属性:
Jasmine仅导出
Jasmine.js
file,但在中Jasmine-ts 代码需要命令文件(围绕第164行),
现在此文件不是导出的一部分,因此它会引发错误:
来修复此茉莉花需要导出
jasmine-ts
使用的命令文件。我在茉莉
package.json
中测试了以下更改,并解决了问题:更改Jasmine
package.json
不是一个很好的解决方案,但目前这是唯一的解决方案我的头顶。我将尝试向茉莉花GitHub存储库打开问题。
The problem is in the in the exports property of jasmine package.json:
Jasmine exports only the
jasmine.js
fileBut in the jasmine-ts code there is a require to command file (around row 164)
Now this file is not part of the exports so it throws the error:
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: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.