[英]TS: Error: Cannot find module (modifying tsconfig does not help)
I am using this library in my project and something really weird is going on.我在我的项目中使用了这个库,并且发生了一些非常奇怪的事情。
This import works:此导入工作:
import {Account} from '@metaplex/js';
While this fails:虽然这失败了:
import {Edition} from "@metaplex/js/lib/programs/metadata";
The error I get is:我得到的错误是:
Error: Cannot find module '@metaplex/js/lib/programs/metadata/accounts/Edition'
Require stack:
- /Users/ilmoi/Dropbox/crypto_bc/sol/nft-armory-node/index.ts
at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)
at Function.Module._resolveFilename.sharedData.moduleResolveFilenameHook.installedValue [as _resolveFilename] (/Users/ilmoi/Dropbox/crypto_bc/sol/nft-armory-node/node_modules/@cspotcode/source-map-support/source-map-support.js:679:30)
at Function.Module._load (node:internal/modules/cjs/loader:778:27)
at Module.require (node:internal/modules/cjs/loader:1005:19)
at require (node:internal/modules/cjs/helpers:102:18)
at Object.<anonymous> (/Users/ilmoi/Dropbox/crypto_bc/sol/nft-armory-node/index.ts:8:19)
at Module._compile (node:internal/modules/cjs/loader:1101:14)
at Module.m._compile (/Users/ilmoi/Dropbox/crypto_bc/sol/nft-armory-node/node_modules/ts-node/src/index.ts:1371:23)
at Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
at Object.require.extensions.<computed> [as .ts] (/Users/ilmoi/Dropbox/crypto_bc/sol/nft-armory-node/node_modules/ts-node/src/index.ts:1374:12) {
code: 'MODULE_NOT_FOUND',
requireStack: [ '/Users/ilmoi/Dropbox/crypto_bc/sol/nft-armory-node/index.ts' ]
}
What's even weirder is that my IDE can easily track down the module and doesn't throw any errors.更奇怪的是,我的 IDE 可以轻松跟踪模块并且不会抛出任何错误。
All the advice online that I was able to find is about changing tsconfig to commonjs
or setting "moduleResolution": "node"
- but I've long done that and no luck.我能找到的所有在线建议都是关于将 tsconfig 更改为
commonjs
或设置"moduleResolution": "node"
commonjs
"moduleResolution": "node"
- 但我早就这样做了,但没有运气。
My tsconfig:我的 tsconfig:
{
"compilerOptions": {
"target": "es6",
"module": "commonjs",
"rootDir": "./",
"moduleResolution": "node",
"resolveJsonModule": true,
"isolatedModules": true,
"allowSyntheticDefaultImports": true,
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"strict": true,
"skipLibCheck": true
}
}
Any advice would be 🙏任何建议都是🙏
Why dont you try this?你为什么不试试这个?
import { Account, programs } from '@metaplex/js';
const { metadata } = programs;
let Edition = metadata.Edition
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.