试图将某些项目的类型(称为payouts-api)发布到另一个project-main
我遇到Cannot find module
错误。
编译项目时,所有内容均已成功编译
但是运行摩卡时我得到Cannot find module 'payouts-api'
。
那是我的payouts-api的package.json 我只发布dist文件夹
{
"name": "payouts-api",
"version": "1.0.15",
"description": "",
"main": "src/index.js",
"types": "./types/payouts-api.d.ts",
"files": [
"/dist"
],
"scripts": {
"clean": "rm -rf ./dist/* ",
"build": "tsc && npm run copyfiles",
"start": "node ./dist/src/index.js",
"lint": "tslint src/**/*",
"serve": "ts-node ./src/index.ts",
"create-declarations": "dts-generator --project ./ --out ./types/payouts-api.d.ts --verbose",
"copyfiles": "copyfiles -u 1 src/api.yaml dist/src",
"start:dev": "nodemon",
"test": "tsc -p . && mocha dist/tests/unit-tests/**/*-spec.js --recursive",
"test:coverage": "tsc -p . && nyc npm test"
},
"author": "",
"dependencies": {
"@types/mocha": "^5.2.7",
<more dependencies....>
},
}
在项目主目录中:
在运行Mocha时,当它尝试使用payouts-api程序包时
我得到:Error: Cannot find module 'payouts-api/dist/types/src/database/entities/BankAccount'
我尝试消费的方式是:
import { BankAccountStatus } from 'payouts-api/dist/types/src/database/entities/BankAccount';