Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

typescript 项目中使用报错 #144

Closed
oevery opened this issue Jun 9, 2024 · 5 comments · Fixed by #145
Closed

typescript 项目中使用报错 #144

oevery opened this issue Jun 9, 2024 · 5 comments · Fixed by #145
Labels

Comments

@oevery
Copy link
Contributor

oevery commented Jun 9, 2024

There are types at '/node_modules/push-all-in-one/dist/index.d.ts', but this result could not be resolved when respecting package.json "exports". The 'push-all-in-one' library may need to update its package.json or typings.

只需要在 exports 中添加 types 就可以解决这个问题

  "exports": {
    ".": {
      "types": "./dist/index.d.ts",
      "import": "./dist/index.mjs",
      "require": "./dist/index.js"
    }
  },
@CaoMeiYouRen
Copy link
Owner

感谢提出 issue并 fix。
另外我想问下这是什么情况下会出现的问题?
如果可以的话,希望给一下 Node.js/Npm/TypeScript 的版本,我好复现下问题。

github-actions bot pushed a commit that referenced this issue Jun 10, 2024
## [3.5.2](v3.5.1...v3.5.2) (2024-06-10)

### 🐛 Bug 修复

* 修复 typescript 中使用找不到声明文件 ([314c051](314c051)), closes [#144](#144)
@CaoMeiYouRen
Copy link
Owner

🎉 This issue has been resolved in version 3.5.2 🎉

The release is available on:

Your semantic-release bot 📦🚀

@oevery
Copy link
Contributor Author

oevery commented Jun 10, 2024

感谢提出 issue并 fix。 另外我想问下这是什么情况下会出现的问题? 如果可以的话,希望给一下 Node.js/Npm/TypeScript 的版本,我好复现下问题。

typescript 项目里应该 tsconfig.json moduleResolution 不是 node 的话应该都会出现,是 node 的话是可以正常解析到的,Bundler、nodenext 都会报错。
typescript 版本是5.4.5,node 是 20.14.0

@CaoMeiYouRen
Copy link
Owner

感谢提出 issue并 fix。 另外我想问下这是什么情况下会出现的问题? 如果可以的话,希望给一下 Node.js/Npm/TypeScript 的版本,我好复现下问题。

typescript 项目里应该 tsconfig.json moduleResolution 不是 node 的话应该都会出现,是 node 的话是可以正常解析道的,Bundler、nodenext 都会报错。

了解~

@oevery
Copy link
Contributor Author

oevery commented Jun 13, 2024

今天在使用中发现上次并没有从根源上解决问题,虽然不会报找不到声明文件的错了,但是使用中会提示

[worker reload] [worker init] The requested module 'socks-proxy-agent' does not provide an export named 'SocksProxyAgent'                             

  import { SocksProxyAgent } from 'socks-proxy-agent';
  ^^^^^^^^^^^^^^^
  SyntaxError: The requested module 'socks-proxy-agent' does not provide an export named 'SocksProxyAgent'

测试发现只要更改 proxy agent 的引入方式:

import HttpsProxyAgent from 'https-proxy-agent';
import SocksProxyAgent from 'socks-proxy-agent';

或者删除掉 package.json 中的 exports 字段即可解决问题。

不太清除这两种解决方案会不会带来新的问题,甚至有点弄不清为啥会出现这么奇怪的问题,所以放上来看看。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants