错误的表达式:非弦乐值传递到typescript中的`ts.resolvetypeRecredectextive'

发布于 2025-02-04 13:09:52 字数 1028 浏览 3 评论 0原文

当我尝试运行ts-node-dev./index.ts时,我会遇到以下错误,我更新了typescript和ts-node-dev,ts-node,但是如果我删除具有@Types的依赖关系,则此错误会继续弹出/xxxx(例如:@type/express)它工作正常。

false表达式:非弦乐值传递给ts.ResolvetypeRecredectiveDixed,可能是通过使用过时的resolvetyperedrectedirectives签名的包装软件包。这可能不是TS本身的问题。

    "dependencies": {
    "ajv": "^8.9.0",
    "axios": "^0.27.1",
    "exceljs": "^4.3.0",
    "express": "^4.17.1",
    "json2csv": "^5.0.7",
    "moment-timezone": "^0.5.33",
    "mysql": "^2.18.1",
    "mysql-utilities": "^1.1.3",
    "q": "^1.5.1",
    "ts-node": "^10.8.0",
    "ts-node-dev": "^2.0.0",
    "typescript": "^4.7.2",
    "winston": "^3.3.3",
    "winston-daily-rotate-file": "^4.5.5"
  },
  "devDependencies": {
    "@types/chai": "^4.2.22",
    "@types/express": "^4.17.11",
    "@types/jest": "^27.4.0",
    "@types/mocha": "^9.0.0",
    "@types/mysql": "^2.15.20",
    "@types/node": "^15.6.1",
    "chai": "^4.3.4",
    "jest": "^27.4.7",
    "mocha": "^9.1.2",
    "ts-jest": "^27.1.3"
  },

When I try to run ts-node-dev./index.ts, I get the below error, I updated my typescript and ts-node-dev, ts-node but this error keeps on popping if I remove dependencies that have @types/XXXX(eg:@types/express) it is working fine.

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.

    "dependencies": {
    "ajv": "^8.9.0",
    "axios": "^0.27.1",
    "exceljs": "^4.3.0",
    "express": "^4.17.1",
    "json2csv": "^5.0.7",
    "moment-timezone": "^0.5.33",
    "mysql": "^2.18.1",
    "mysql-utilities": "^1.1.3",
    "q": "^1.5.1",
    "ts-node": "^10.8.0",
    "ts-node-dev": "^2.0.0",
    "typescript": "^4.7.2",
    "winston": "^3.3.3",
    "winston-daily-rotate-file": "^4.5.5"
  },
  "devDependencies": {
    "@types/chai": "^4.2.22",
    "@types/express": "^4.17.11",
    "@types/jest": "^27.4.0",
    "@types/mocha": "^9.0.0",
    "@types/mysql": "^2.15.20",
    "@types/node": "^15.6.1",
    "chai": "^4.3.4",
    "jest": "^27.4.7",
    "mocha": "^9.1.2",
    "ts-jest": "^27.1.3"
  },

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

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

发布评论

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

评论(15

っ左 2025-02-11 13:09:52

升级到“ TS节点”:“ 10.8.1”为我解决了问题。

Upgrading to "ts-node": "10.8.1" solved the issue for me.

梦幻的心爱 2025-02-11 13:09:52

解决方案

我的问题是由从4.6升级到^4.7引起的,我这样做是为了解决它:

# With NPM
npm install ts-node-dev@latest ts-node@latest

# With yarn
yarn upgrade ts-node-dev@latest ts-node@latest

# With pnpm
pnpm up ts-node-dev@latest ts-node@latest

我使用“ ts-node”:“^ 10.7.0““ ts-node-dev”:“^1.1.8”,在升级两个dev-deps后,解决了问题。

为什么

TS 4.7升级“ noreferrer”>解决模式(请参阅最后一行)。鉴于ts-nodets-node-dev正在内部使用旧的分辨率模式,将其更新为以后的版本@> = 10.8.0 和ts-node-dev@= 2,解决此问题。

升级后仅升级“ ts-node”(来自houssem hichri的答案),因此添加了本章

@khachaturstepanyan tl; Dr

,因为我正在使用“ ts-node-dev”:“^1.1.8”,因此仍然存在错误。

Solution

My problem was caused by upgrading typescript from 4.6 to ^4.7, and I did this to fix it:

# With NPM
npm install ts-node-dev@latest ts-node@latest

# With yarn
yarn upgrade ts-node-dev@latest ts-node@latest

# With pnpm
pnpm up ts-node-dev@latest ts-node@latest

I was using "ts-node": "^10.7.0", and "ts-node-dev": "^1.1.8", after upgrading both dev-deps, the issue was solved.

Why

TS 4.7 upgrades the resolution mode (see the last line). Given that the ts-node and ts-node-dev are using the old resolution mode internally, updating them to the later version, to be exact ts-node@>=10.8.0 and ts-node-dev@>=2, fixes this problem.

This chapter is added for @KhachaturStepanyan

TL;DR

After upgrading only "ts-node"(from Houssem Hichri's answer), the error remained, because I was using "ts-node-dev": "^1.1.8".

剧终人散尽 2025-02-11 13:09:52

我将TypeScript升级到4.7.4,然后通过将ts-loader 升级到9.3.1来修复。

I was upgrading typescript to 4.7.4 and I fixed this by upgrading ts-loader to 9.3.1.

别想她 2025-02-11 13:09:52

Try downgrading to [email protected]. This may be needed if this issue occurs without ts-node installed.

舞袖。长 2025-02-11 13:09:52

如果以上问题对您不起作用。...

尝试更新TS-loader ....

命令是:npm install ts-loader@最新

If none of the above issues works for you....

Do try updating ts-loader also....

The command is: npm install ts-loader@latest

神仙妹妹 2025-02-11 13:09:52

纱线添加-d ts节点npm install -save-dev ts-node解决问题

yarn add -D ts-node or npm install --save-dev ts-node solves the problem

老娘不死你永远是小三 2025-02-11 13:09:52

我也有同样的问题。我在 webpack configs 之前用babel-loader替换了ts-loader

{
            test: /\.tsx?$/,
            use: [
                {
                    loader: "ts-loader"
                },
            ],
            exclude: /node_modules/,
        },
        {
            test: /\.ts$/,
            loader: 'ts-loader',
            exclude: /node_modules/, 
        },

之后:

{
            test: /\.tsx?$/,
            use: [
                {
                    loader: "babel-loader"
                },
            ],
            exclude: /node_modules/,
        },
        {
            test: /\.ts$/,
            loader: 'babel-loader',
            exclude: /node_modules/, 
        },

I had the same issue. I replaced ts-loader with babel-loader in webpack configs

before:

{
            test: /\.tsx?$/,
            use: [
                {
                    loader: "ts-loader"
                },
            ],
            exclude: /node_modules/,
        },
        {
            test: /\.ts$/,
            loader: 'ts-loader',
            exclude: /node_modules/, 
        },

after:

{
            test: /\.tsx?$/,
            use: [
                {
                    loader: "babel-loader"
                },
            ],
            exclude: /node_modules/,
        },
        {
            test: /\.ts$/,
            loader: 'babel-loader',
            exclude: /node_modules/, 
        },
撩动你心 2025-02-11 13:09:52

使用typeorm 0.2.43& Typescript 4.9.5

在我的代码上解决的问题,将TS节点升级到10.9.1(现在是最后版本)

npm install ts-node@latest -D

Using typeorm 0.2.43 & typescript 4.9.5

Problem fixed on my code upgrading ts-node to 10.9.1 (lastest version by now)

npm install ts-node@latest -D
机场等船 2025-02-11 13:09:52

使用以下版本对我有用。

TS节点10.8.1& 节点14.17.3

Using the following versions worked for me.

ts-node 10.8.1 & node 14.17.3

孤独患者 2025-02-11 13:09:52

我的问题是,即使本地项目中的一个已经很好,我有一个过时的全球版本的TS节点,这引起了问题。我通过卸载全局版本和使用NPX版本来解决它。

NPM卸载-G TS节点

npx ts-node app.ts

My issue was that I had an out of date global version of ts-node that was causing issues, even though the one in the local project was fine. I resolved it by uninstalling the global version and using the npx version.

npm uninstall -g ts-node

npx ts-node app.ts

念﹏祤嫣 2025-02-11 13:09:52

由于没有人提到它,所以我正在升级包装的版本,而在升级和构建此错误之间弹出的某个地方。我无法弄清楚先前的答案是否有用,所以我只是在验证我的package.json.json具有我想要的依赖项后,我只是nuked rm package-lock.json。再次使用新的软件包 - 洛克.json构建后,我的项目成功了。

Since no one mentioned it, I was upgrading versions of a package, and somewhere between upgrading and building this error popped up. I couldn't figure out if the previous answers were useful, so I just nuked rm package-lock.json after verifying that my package.json has the dependencies I want. After building again with a new package-lock.json, my project succeeded.

幸福不弃 2025-02-11 13:09:52

可能是一个节点版本错误,因此请尝试更新您的节点版本,然后检查package.json文件

probably it's a node versioning error, so try to update your node version and check package.json file

零度℉ 2025-02-11 13:09:52

将TS-Loader和TS节点更新为最新,在我的情况下已解决

npm install -D ts-loader@latest ts-node@latest

updating ts-loader and ts-node to latest , resolved in my case

npm install -D ts-loader@latest ts-node@latest
酒废 2025-02-11 13:09:52

这不是TS错误。升级到最新版本是推荐的路径。

但是,在我的应用程序转移到最新版本的TS中,没有提供显着优势,因此,我将TS降级到V4.2.4版本从v4.9.5降低,以暂时解决该问题。

如果您的情况与我的情况相似(其他高度优先级),请延迟TS升级策略,以便如果不提出质量问题。

It is not a TS error. Upgrading to the latest version is the recommended path.

However, in my app moving to the latest version of TS did not provide significant advantages hence, I downgraded the TS to the version v4.2.4 from v4.9.5 to resolve the issue temporarily.

In case your situation is similar to mine (other high priorities) then delay TS upgrade strategy for time being if it is not posing quality issues.

绾颜 2025-02-11 13:09:52

以下工作

"devDependencies": {
    "@types/cors": "^2.8.17",
    "@types/express": "^4.17.21",
    "@types/morgan": "^1.9.9",
    "@types/node": "^14.18.63",
    "@typescript-eslint/eslint-plugin": "^4.33.0",
    "@typescript-eslint/parser": "^4.33.0",
    "eslint": "^7.32.0",
    "nodemon": "^2.0.22",
    "ts-node": "^10.9.2",
    "typescript": "^4.9.5"
  },
  "dependencies": {
    "cors": "^2.8.5",
    "env-cmd": "^10.1.0",
    "express": "^4.21.1",
    "fs": "^0.0.1-security",
    "helmet": "^4.6.0",
    "morgan": "^1.10.0",
    "ts-node-dev": "^2.0.0"
  }

Following worked >>

"devDependencies": {
    "@types/cors": "^2.8.17",
    "@types/express": "^4.17.21",
    "@types/morgan": "^1.9.9",
    "@types/node": "^14.18.63",
    "@typescript-eslint/eslint-plugin": "^4.33.0",
    "@typescript-eslint/parser": "^4.33.0",
    "eslint": "^7.32.0",
    "nodemon": "^2.0.22",
    "ts-node": "^10.9.2",
    "typescript": "^4.9.5"
  },
  "dependencies": {
    "cors": "^2.8.5",
    "env-cmd": "^10.1.0",
    "express": "^4.21.1",
    "fs": "^0.0.1-security",
    "helmet": "^4.6.0",
    "morgan": "^1.10.0",
    "ts-node-dev": "^2.0.0"
  }
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文