这里有一个类似的帖子:
My custom NPM Package is not found,
但这并没有解决我的问题。
找不到模块“@dc_microurb/common”的声明文件。'/Users//Projects/ticketing/auth/node_modules/@dc_microurb/common/build/index.js‘隐式地具有“任意”类型。如果存在
npm install @types/dc_microurb__common,可以尝试使用它,或者添加一个新的声明(.d.ts)文件,其中包含‘`declare模块’@dc_microurb/ module‘;
这里没有@types/dc_microurb__common,我不清楚为什么它建议创建一个新的.d.ts文件,而这在构建过程中会自动发生。
这是我发布的包中的package.json文件:
{
"name": "@dc_microurb/common",
"version": "1.0.5",
"description": "",
"main": "./build/index.js",
"types": "./build/index.d.ts",
"files": [
"./build/**/*"
],
"scripts": {
"clean": "del ./build",
"build": "npm run clean && tsc",
"pub": "git add . && git commit -m \"Updates\" && npm version patch && npm run build && npm publish"
},
"keywords": [],
"author": "",
"license": "ISC",
"devDependencies": {
"del-cli": "^3.0.1",
"typescript": "^4.0.5"
},
"dependencies": {
"@types/cookie-session": "^2.0.41",
"@types/express": "^4.17.9",
"@types/jsonwebtoken": "^8.5.0",
"cookie-session": "^1.4.0",
"express": "^4.17.1",
"express-validator": "^6.6.1",
"jsonwebtoken": "^8.5.1"
}
}谁有在npm上发布软件包的经验,其中涉及TypeScript?我不清楚为什么我的auth服务没有找到这个包,当它成功地安装在该服务中时。
我是否在common/src/index.ts文件中导出的方式上搞砸了?
export * from './errors/bad-request-error';
export * from './errors/custom-errors';
export * from './errors/database-connection-error';
export * from './errors/not-authorized-error';
export * from './errors/not-found-error';
export * from './errors/request-validation-error';
export * from './middlewares/current-user';
export * from './middlewares/error-handler';
export * from './middlewares/require-auth';
export * from './middlewares/validate-request';是否所有这些都必须在module.exports中而不是?
发布于 2020-11-11 21:26:54
因此,在回顾了媒体上的几个博客之后,我注意到了一些事情。
tsconfig.js里,这个丢失了:/*高级选项/ "forceConsistentCasingInFileNames":真/不允许不一致*/
因此,我手动添加了它,其次,我注意到了一些我想要删除的东西,但是忘记了。所以,不是这样的:
{
"name": "@dc_microurb/common",
"version": "1.0.5",
"description": "",
"main": "./build/index.js",
"types": "./build/index.d.ts",
"files": [
"./build/**/*"
],我需要这样做:
{
"name": "@dc_microurb/common",
"version": "1.0.6",
"description": "",
"main": "./build/index.js",
"types": "./build/index.d.ts",
"files": [
"build/**/*"
],在做了这些修正之后,现在我的包可以用于我的auth服务了。
https://stackoverflow.com/questions/64793159
复制相似问题