相关疑难解决方法(0)

Node v13 / Jest / ES6 — 对没有 babel 或 esm 的模块的原生支持

是否可以在不使用esm或不使用 Jest 的情况下使用 Jest 测试 ES6 模块babel?由于node v13本机支持 es6 已经尝试过:

//package.json
{
  …
  "type": "module"
  …
}



//__tests__/a.js
import Foo from '../src/Foo.js';


$ npx jest

Jest encountered an unexpected token
…
Details:

/home/node/xxx/__tests__/a.js:1
import Foo from '../src/Foo.js';
^^^^^^

SyntaxError: Cannot use import statement outside a module
Run Code Online (Sandbox Code Playgroud)

当 babel 添加一个转译器时,它可以工作,但是 es6 模块也可以在本地使用吗?

node.js ecmascript-6 jestjs

25
推荐指数
2
解决办法
7219
查看次数

如何在launch.json中配置vs代码工作目录

我使用的Goland(同webstorm /的IntelliJ等),IDE和调试配置存在时,你可以配置一个地方working directory现在我试着将工作与VSCODE,我不觉得这配置,有点研究后,我发现下面的JSON的应处置这,但找不到工作目录的正确位置

例如这是我的工作目录

/Users/i022226/go/src/myapp

"configurations": [{
            "name": "Launch Package",
            "type": "go",
            "request": "launch",
            "mode": "debug",
            "program": "${workspaceRoot}"
        },
        {
            "name": "Launch Package",
            "type": "go",
            "request": "launch",
            "mode": "debug",
            "program": "${workspaceRoot}"
        },
        {
            "name": "Launch",
            "type": "go",
            "request": "launch",
            "mode": "debug",
            "remotePath": "",
            "port": 2345,
            "host": "127.0.0.1",
            "program": "${fileDirname}",
            "env": {},
            "args": [],
            "showLog": true
        } 
Run Code Online (Sandbox Code Playgroud)

在“ launch.json添加配置”按钮中,当我键入内容时,cwd我没有任何输入,有任何想法吗?

在这篇文章中cwd是在,option但我找不到option https://github.com/Microsoft/vscode/issues/856

visual-studio-code

5
推荐指数
2
解决办法
5330
查看次数