在将Solana-cli更新为1.9.4,Anchor-cli更新为0.20.1和其他本地npm版本后,我得到了此错误.
Local npm package: @project-serum/anchor 0.18.2
Solana program dependencies: anchor-lang 0.18.2, anchor-spl 0.18.2, solana-program 1.9.4
Global environment: Rust 1.57.0, solana-cli 1.9.4, @project-serum/anchor-cli 0.20.1Anchor.toml脚本命令:该命令在另一个repo上工作得很好:
test = "yarn run ts-mocha -p ./tsconfig.json -t 1000000 tests/**/*.ts"问题是m1.ts文件不能从其他ts文件导入函数!?
在我的utils.ts里
export const log1 = console.log;在我的m1文件中:
import { log1 } from './utils';
describe('scenario1', async () => {
it('initialize', async () => {
log1('\n---------== init');
});
});导入的log1函数或任何其他函数都会导致未知的文件扩展名".ts“错误!!??
我的本地包依赖项:"mocha":"^9.1.3","ts-mocha":“^9.0.0-alpha1 1”,“ts-节点”:"^10.4.0","typescript":"^4.5.4“
请给我建议。谢谢

发布于 2022-04-16 22:20:37
因为test命令可以执行其他repo操作,这意味着系统中已经有yarn和ts-node。
tsconfig.json文件config.json应该如下所示:
{
"compilerOptions": {
"types": ["mocha", "chai"],
"typeRoots": ["./node_modules/@types"],
"lib": ["es2015"],
"module": "commonjs",
"target": "es6",
"esModuleInterop": true
}
}由于您正在导入一个文件,所以必须设置"esModuleInterop": true。这允许从模块中推断类型。
https://stackoverflow.com/questions/70679635
复制相似问题