“类型”:“模块”导入问题
使用JS图书馆,我为需要和进口的事实而苦苦挣扎。当我在软件包中编写“ type”:“模块”时,json,然后导入但不需要,而当我不这样做时,情况恰恰相反。我没有如何导入两个库中的两个。
我会导入这样的fs:
const fs = require('fs')
在另一个文件中,我正在以这样的方式导入pythonshell:
import { PythonShell } from 'python-shell'
有没有办法让“ type”:“模块”仅适用于我的软件包中的一个库。还是我可以像另一个一样导入一个关键词(导入或需要)?
谢谢你, 祝你有美好的一天。
Using js librairies, I struggle with the fact that require and import are not suitable together. When I write "type": "module" in the package.json, then import works but require doesn't, and when I don't, the opposite happens. I don't get how to import both of the two librairies.
I import fs like this :
const fs = require('fs')
and in the other file I am importing PythonShell like this :
import { PythonShell } from 'python-shell'
Is there a way to have "type" : "module" only applying for one librairy in my package.json ? Or can I import one like the other in order to use only one key word (import or require) ?
Thank you,
have a great day.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您不一定需要使用导入来使用python-shell的
pythonshell
类,您可以只使用require()
,因此您的代码看起来像这样You don't necessarily need to use import to use the
PythonShell
class from python-shell, you can just userequire()
so your code would look like this