当我运行tsc index.ts
来编译导入了AXIOS的打字脚本时,我得到了一个错误.
我已经在全局安装了打字脚本.
创建了一个干净的目录,我所做的是运行npm init -y
,NPM安装axios,然后在其中创建我的index.ts a导入axios:
import axios from "axios";
const url = 'https://jsonplaceholder.typicode.com/todos/1';
axios.get(url).then(response => {
console.log(response.data);
});
When I run tsc index.ts
to compile I get the following error:
Also installed the tsconfig.json with comand tsc --init
but didn't change anything. Current configuration the default:
{
"compilerOptions": {
"target": "es2016",
"module": "commonjs",
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"strict": true,
"skipLibCheck": true
}
}
如果我运行ts-node index.ts
,index.ts将被编译,并且没有错误.
如何在运行tsc index.ts
进行编译时修复此错误?
node version v18.17.1
npm version 10.4.0
typescript version 5.3.3
axios 1.6.7
谢谢大家!