簡體   English   中英

如何使用無服務器捆綁包在無服務器框架項目中調試 Visual Studio Code 中的測試?

[英]How can I debug tests in Visual Studio Code with a serverless-framework project using the serverless-bundle package?

我有一個使用 serverless-bundle 包的無服務器框架項目,以便我可以使用 ES6 導入和導出。

我目前有一個失敗的測試。 當我單擊 Visual Studio Code 中的“調試”鏈接時,調試會話因測試代碼第 1 行的以下原因而失敗: SyntaxError: Cannot use import statement outside a module

我正在處理的測試代碼位於: https : //github.com/groffcole/art-center-service/blob/master/ports/GalleriesHttpPort.test.js

我能做些什么來解決這個問題?

謝謝。

嘗試使用 const "" = require() 看看是否有效。 如果是這樣,您安裝了哪個版本的 nodejs? 您是否將其設置為使用 es6 導入? ES^ 導入在節點 13 https://nodejs.org/api/esm.html#esm_introduction https://nodejs.org/dist/latest-v13.x/docs/api/modules.html#modules_module_exports仍處於實驗階段

let func1 = ()=>{
return "Hello"
}
let func2 = ()=>{
return "World"
}
module.exports ={func1:func1,func2:func2}

暫無
暫無

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

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