我的目标是在verdaccio上为常用的typescript函数构建和发布一个包,verdaccio是一个运行在docker上的npm注册表。
我建立了我的打字包。这是我的项目结构
package.json
{
"name": "communications",
"version": "1.0.0",
"description": "provides functional way of interacting with NATS",
"main": "lib/index.js",
"types": "lib/index.d.ts",
"files": [
"lib/**/*"
],
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"build": "tsc",
"library": "tsc && npm unpublish --force --registry http://localhost:4873 && npm publish --registry http://localhost:4873"
},
"author": "bumblebee",
"license": "ISC",
"dependencies": {
"nats": "^2.9.2"
}
}
这是我的tsconfig.json
{
"compilerOptions": {
/* Language and Environment */
"target": "ES2016" /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */,
/* Modules */
"module": "CommonJS" /* Specify what module code is generated. */,
/* Disallow 'import's, 'require's or '<reference>'s from expanding the number of files TypeScript should add to a project. */
/* JavaScript Support */
// "allowJs": true, /* Allow JavaScript files to be a part of your program. Use the 'checkJS' option to get errors from these files. */
// "checkJs": true, /* Enable error reporting in type-checked JavaScript files. */
// "maxNodeModuleJsDepth": 1, /* Specify the maximum folder depth used for checking JavaScript files from 'node_modules'. Only applicable with 'allowJs'. */
/* Emit */
"declaration": true /* Generate .d.ts files from TypeScript and JavaScript files in your project. */,
"declarationMap": true /* Create sourcemaps for d.ts files. */,
"outDir": "./lib" /* Specify an output folder for all emitted files. */,
/* Interop Constraints */
"esModuleInterop": true /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */,
"forceConsistentCasingInFileNames": true /* Ensure that casing is correct in imports. */,
/* Type Checking */
"strict": true /* Enable all strict type-checking options. */,
"noImplicitAny": true /* Enable error reporting for expressions and declarations with an implied 'any' type. */,
"strictNullChecks": true /* When type checking, take into account 'null' and 'undefined'. */,
"strictFunctionTypes": true /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */,
"strictBindCallApply": true /* Check that the arguments for 'bind', 'call', and 'apply' methods match the original function. */,
"strictPropertyInitialization": true /* Check for class properties that are declared but not set in the constructor. */,
"noImplicitThis": true /* Enable error reporting when 'this' is given the type 'any'. */,
"alwaysStrict": true /* Ensure 'use strict' is always emitted. */,
"noUnusedLocals": true /* Enable error reporting when local variables aren't read. */,
"noUnusedParameters": true /* Raise an error when a function parameter isn't read. */,
"noUncheckedIndexedAccess": true /* Add 'undefined' to a type when accessed using an index. */,
"noImplicitOverride": true /* Ensure overriding members in derived classes are marked with an override modifier. */,
/* Completeness */
"skipLibCheck": true /* Skip type checking all .d.ts files. */
},
"include": ["src"],
"exclude": ["node_modules", "**/__tests__/*"]
}
这是我的.npmignore
package-lock.json
node_modules/
这是运行tsc后我的库中的文件夹结构
当我尝试使用安装该项目时,该项目已成功发布在verdaccio中
npm install communications --registry http://localhost:4873/
这是我得到
packageiderjson是我得到的唯一文件。没有别的。当然,这会导致编译错误,即使导入任何东西。
为什么我的lib文件夹完全被忽略了,没有在npm包中发布?
那是
1条答案
按热度按时间k2arahey1#
我所做的一切都是正确的。我没有使用命令
这将创建一个压缩包communication.nats-1.0.0.tgz,该压缩包也已发布。只有在此之后,我才能够获得所有所需的文件。这是一个愚蠢的错误,但我所遵循的文章根本没有提到这一点。序列应该如下: