繁体   English   中英

从 nx 中的服务应用程序导入此库时,库中的内部 json 导入中断

[英]internal json import in a library breaks when importing this library from a served app in nx

在我的库中,我正在导入一个 json 文件,该文件在运行该库中的代码(例如故事书、linter)时可以正常工作,但是当我在 nx 提供的应用程序中从该库导入时,我收到此错误:

Cannot find module './example.json'. Consider using '--resolveJsonModule' to import module with '.json' extension.

我是否也必须在应用程序的 tsconfig.json 中添加"resolveJsonModule": true, 感觉像是应该在图书馆解决的问题。

添加 "resolveJsonModule": true 到您的编译器选项

"compilerOptions": {
    "forceConsistentCasingInFileNames": true,
    "strict": true,
    "noImplicitReturns": true,
    "noFallthroughCasesInSwitch": true,
    "resolveJsonModule": true
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM