javascript - nodejs找不到本地文件夹模块

标签 javascript node.js typescript ecmascript-6

我有一个简单的 Typescript 和 NodeJS Visual Studio 项目,编译成功,但收到有关无法找到本地模块的 Node 运行时错误。

这是给出的错误:

enter image description here

我不明白为什么 Typescript 构建成功,但 Node 运行时无法解析模块。作为记录,我的 package.json 文件中有 "type": "module" 。为了相关性,这是我的目录树(build 是 Typescript 构建的输出目录):

enter image description here

这是错误所提示的文件,build\application.js:

enter image description here

最后,这是我的package.json

enter image description here

如有任何帮助,我们将不胜感激。我觉得我在这里错过了一些东西。

编辑:添加 source\index.js 和 source\test.js

enter image description here

enter image description here

最佳答案

似乎您只使用了文件夹的名称

'。/来源'

例如,您需要指向确切的文件

'。/源/索引'

希望这有帮助!

关于javascript - nodejs找不到本地文件夹模块,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60481104/

相关文章:

javascript - Pubnub - 取消订阅特定 channel 的所有活跃用户

javascript - 更新 firestore 文档中嵌套对象中的字段?

javascript - document.getSelection() 和 window.getSelection() 的区别

node.js - 如何在 Node.js CLI 应用程序中执行 HTTP 请求缓存,该缓存在应用程序退出后仍然存在?

jquery - 类型 'modal' Angular6 上不存在属性 'JQuery'

javascript - 使用 javascript 或 CSS 扩展表格行

node.js - 删除 express 中的 Etag header

javascript - 显示所有连接的用户 Discord.js

reactjs - typescript + VS 代码 : Cannot find module "myimage.png"

javascript - Angular : set reactive form with dynamic looping inputs