我只是用npm install -g ts-node安装了ts-node,但是我不能执行REPL,它给了我这个错误:
/usr/lib/node_modules/ts-node/src/index.ts:478
throw new TypeError('Could not find a compatible `parseConfigFile` function')
^
TypeError: Could not find a compatible `parseConfigFile` function
at readConfig (/usr/lib/no
我正在学习一个教程,这个家伙使用ts节点,所以我做了同样的操作,并通过纱线安装了它,但是它显示了这个错误。
ts-node : The term 'ts-node' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the
name, or if a path was included, verify that the path is correct and try again.
At line:1 c
我正在使用ts-node运行我的项目,并得到以下错误
TSError: ⨯ Unable to compile TypeScript:
spec/crons/dailyjob.spec.ts(51,9): error TS2589: Type instantiation is excessively deep and possibly infinite.
at createTSError (C:\Users\joe\Documents\projects\client1\node_modules\ts-node\src\index.ts:820:12)
at reportTSE
我的src文件夹中有一个名为foo.ts的文件,如下所示:
import * as cdk from 'aws-cdk-lib';
console.log('hello world');
const app = new cdk.App();
当我运行ts-node src/foo.ts时,我得到以下错误:SyntaxError: Cannot use import statement outside a module --如果我只删除导入控制台--它可以工作.当我将"type": "module",添加到package.json
我在开发的时候遇到了一些ts-node的问题。 我想测试一些东西,所以你知道,评论是我最好的朋友。但是对于ts-node,我得到了这个错误: 'foo' is declared but its value is never read 但我不想注释所有未使用的变量,因为这些变量实际上对测试后的代码很有用。 那么,有没有像ts-node --please-let-me-work这样的解决方案来忽略这些错误呢? 谢谢;)
我正在努力学习。我写了两个文件作为一个简单的例子。它们都位于同一个目录中,目前不在与package.json相同的文件夹中。
/package.json
/src/build-lib/run-ts.js
/src/build-lib/Test.ts
run-ts.js
require('ts-node').register();
const Test = require('./Test.ts').Test; // Tried with and without .ts extension
const tester = new Test();
tester.log(
我想测试一些我写的打字代码。
到目前为止,我所知道的最好的方法是运行ts-node my-file-name.ts。
不过,我想让它更具交互性,类似于Python REPL允许您导入模块,然后随心所欲地调用REPL中的函数。
例如,会话可能如下所示
$ ts-node
> import my-file-name.ts
> myFunctionFromMyFile("specialParam")
> "you just called a function from my-file-name.ts with param specialParam"
我想导入一个graphql文件,但是我得到了一个错误
从“./schema/schema.Graphql”导入typeDefs;
10 import typeDefs from "./schema/schema.graphql";
~~~~~~~~~~~~~~~~~~~~~~~~~
at createTSError (C:\Users\darkc\Desktop\New folder (2)\server\node_modules\ts-node\src\index.ts:750:12)
at reportTSE