简体   繁体   English

TS:错误:找不到模块(修改 tsconfig 没有帮助)

[英]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.

相关问题 使用 ts-node 转译 mocha 测试时,我找不到模块“tsconfig/register” - when transpiling mocha test using ts-node i cannot find module 'tsconfig/register' Typescript Nodejs Dockerfile:错误 TS5057:在指定目录中找不到 tsconfig.json 文件:'.' - Typescript Nodejs Dockerfile: error TS5057: Cannot find a tsconfig.json file at the specified directory: '.' 错误 TS2307:找不到模块(外部、私有模块) - error TS2307: Cannot find module (external, private module) 打字稿错误在 tsconfig.json 中将模块更改为“umd”或“amd”时找不到模块“typescript-Collections” - Typescript error Cannot find module 'typescript-Collections' when changing the module to “umd” or “amd” in tsconfig.json 错误 TS2307:找不到模块“bluebird” - error TS2307: Cannot find module 'bluebird' 错误 TS2307:找不到模块“加密” - error TS2307: Cannot find module 'crypto' ts-node-dev 遇到错误:“找不到模块&#39;typescript&#39;” - ts-node-dev runs into an error: "Cannot find module 'typescript'" 错误:找不到模块“./candy-machine-cli.ts” - Error: Cannot find module './candy-machine-cli.ts' typescript 找不到名称 'provide'.ts(2304) 错误 app.module.ts - typescript cannot find name 'provide'.ts(2304) error app.module.ts 找不到模块,因为 tsconfig.json 中提到了路径 - cannot find module since the path is mentioned in the tsconfig.json
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM