我是打字稿和表達的新手。我正在嘗試使用 運行最簡單的快速應用程式ts-node-dev,但出現以下錯誤。
> ./node_modules/.bin/ts-node-dev src/index.ts 16:07:40
[INFO] 16:07:42 ts-node-dev ver. 1.1.8 (using ts-node ver. 9.1.1, typescript ver. 4.7.2)
Compilation error in /home/lht/microservice/ticketing/auth/src/index.ts
Error: Debug Failure. False expression: Non-string value passed to `ts.resolveTypeReferenceDirective`, likely by a wrapping package working with an outdated `resolveTypeReferenceDirectives` signature. This is probably not a problem in TS itself.
at Object.<anonymous> (/home/lht/microservice/ticketing/auth/src/index.ts:1:7)
at Module._compile (internal/modules/cjs/loader.js:778:30)
at Module._compile (/home/lht/microservice/ticketing/auth/node_modules/source-map-support/source-map-support.js:568:25)
at Module.m._compile (/tmp/ts-node-dev-hook-8101223397369532.js:69:33)
at Module._extensions..js (internal/modules/cjs/loader.js:789:10)
at require.extensions.(anonymous function) (/tmp/ts-node-dev-hook-8101223397369532.js:71:20)
at Object.nodeDevHook [as .ts] (/home/lht/microservice/ticketing/auth/node_modules/ts-node-dev/lib/hook.js:63:13)
at Module.load (internal/modules/cjs/loader.js:653:32)
at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
at Function.Module._load (internal/modules/cjs/loader.js:585:3)
[ERROR] 16:07:42 Error: Debug Failure. False expression: Non-string value passed to `ts.resolveTypeReferenceDirective`, likely by a wrapping package working with an outdated `resolveTypeReferenceDirectives` signature. This is probably not a problem in TS itself.
以下是我的index.ts檔案。
import express from "express";
import { json } from "body-parser";
const app = express();
app.use(json());
app.listen(3000, () => {
console.log("Listening on port 3000!");
});
這是我的package.json檔案
{
"name": "auth",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"start": "ts-node src/index.ts"
},
"keywords": [],
"author": "",
"license": "ISC",
"devDependencies": {},
"dependencies": {
"@types/express": "^4.17.13",
"@types/node": "^17.0.35",
"express": "^4.18.1",
"ts-node": "^10.8.0",
"ts-node-dev": "^1.1.8",
"typescript": "^4.7.2"
}
}
我想知道我正在做的某些配置是否錯誤。提前致謝。
uj5u.com熱心網友回復:
只需在我的檔案中將ts-node-dev版本從1.1.8更改為 ,然后再次運行,錯誤就會消失。2.0.0-0package.jsonnpm install
{
"name": "auth",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"start": "ts-node src/index.ts"
},
"keywords": [],
"author": "",
"license": "ISC",
"devDependencies": {},
"dependencies": {
"@types/express": "^4.17.13",
"@types/node": "^17.0.35",
"express": "^4.18.1",
"ts-node": "^10.8.0",
"ts-node-dev": "^2.0.0-0",
"typescript": "^4.7.2"
}
}
uj5u.com熱心網友回復:
我觀察到,為什么其他服務作業正常,除了一個。我發現,失敗的服務是用不同的 TS 版本編譯的。在我更改了 TS 版本之后
"typescript": "^4.6.3"
至
"typescript": "4.6.4"
這也解決了這個問題。

uj5u.com熱心網友回復:
我從一個新構建的 typeorm 應用程式 ( npx create-express-typescript-application my-app -t typeorm) 中遇到了這個問題。頂ts-node一下就^10.8.0解決了問題。
轉載請註明出處,本文鏈接:https://www.uj5u.com/caozuo/481704.html
標籤:javascript 打字稿 表示 包.json ts节点
