dist
├── another.cjs
├── another.d.ts
├── another.mjs
├── index.cjs
├── index.d.ts
├── index.mjs
└── types.d.ts
a的package.json:
{
"name": "a",
"version": "1.0.0",
"main": "dist/index.cjs",
"module": "dist/index.mjs",
"types": "dist/index.d.ts",
"exports": {
".": {
"import": "./dist/index.mjs",
"require": "./dist/index.cjs",
"types": "./dist/index.d.ts"
},
"./another": {
"import": "./dist/another.mjs",
"require": "./dist/another.cjs",
"types": "./dist/another.d.ts"
},
"./types": "./dist/types.d.ts"
},
"files": [
"dist"
],
...
}
在另一个项目中通过
import test from 'a/another'
调用 a ,然后报错:
Cannot find module 'a/another' or its corresponding type declarations.ts(2307)
查询 chatgpt 无果,所以来请教各位大佬