我创建了一个TS包并将其发布在npm上。当我在一个简单的ts项目上测试我的包时,它是有效的,但当我在vue或react项目上测试它时,我得到了这个错误。
signals.js?2678:30 Uncaught TypeError: Cannot read property 'signals' of undefined
at normalizeSignal (signals.js?2678:30)
at Array.map (<anonymous>)
at getSignals (signals.js?2678:10)
at getSignalsByName (main.js?578e:9)
at eval (main.js?578e:23)
at Object../node_modules/human-signals/build/src/main.js (chunk-vendors.js:1343)
at __webpack_require__ (app.js:849)
at fn (app.js:151)
at eval (error.js?b472:2)
at Object../node_modules/ytb-d/node_modules/execa/lib/error.js
我不知道为什么。这些错误指的是我在库中使用的一个包。我在npm上的包裹是ytb-d。如果有人有解决方案
对于我的tsconfig,它只是:
{
"compilerOptions": {
"module": "commonjs",
"esModuleInterop": true,
"target": "es2017",
"moduleResolution": "node",
"sourceMap": true,
"outDir": "dist",
"baseUrl": ".",
"skipLibCheck": true,
"declaration": true,
"paths": {
"*": ["node_modules/*"]
}
},
"include": ["src/**/*"],
"exclude": ["node_modules", ".vscode"]
}