簡體   English   中英

我正在為 node.js 使用 ES6 語法,並且我已導出模塊但嘗試導入時出現錯誤無法找到模塊

[英]I am using ES6 syntax for node.js and I have exported module but trying to import gives error Cannot find module

索引.js

import { Time} from './service/passport';

護照.js

const Time = async () => {
   console.log('done');
}

export { Time }

我在 node.js 中使用 EcmaScript 或 es6,但是當我嘗試導出上面的模塊時,它給了我錯誤無法找到模塊但我已經導出模塊不知道為什么仍然出現錯誤任何幫助將不勝感激

只需要添加文件擴展名而不是

import { Time} from './service/passport';

采用

import { Time} from './service/passport.js';

將會完成

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM