tsx找不到模块“ xxx”

时间:2020-03-07 04:07:44

标签: typescript yarnpkg tsx yarn-v2

我正在使用yarn 2安装依赖项程序包,并使用yarn start命令顺利启动项目,但是vscode总是提醒我找不到任何本地模块。

enter image description here

这是我的tsconfig.json文件:

{
  "compilerOptions": {
    "target": "es5",
    "lib": [
      "dom",
      "dom.iterable",
      "esnext"
    ],
    "allowJs": true,
    "skipLibCheck": true,
    "esModuleInterop": true,
    "allowSyntheticDefaultImports": true,
    "strict": false,
    "forceConsistentCasingInFileNames": true,
    "module": "esnext",
    "moduleResolution": "node",
    "resolveJsonModule": true,
    "isolatedModules": true,
    "noEmit": true,
    "jsx": "react"
  },
  "include": [
    "src"
  ]
}

这是我的文件夹结构:

enter image description here

1 个答案:

答案 0 :(得分:3)

您可以使用location / { ..... rewrite_by_lua_block { # Get oring nginx var $uri,if u want , ucant change to $request_uri ,$args ... local uri = ngx.var.uri # use api below to decode args ngx.req.set_uri_args(ngx.unescape_uri(ngx.var.args)); # use set_uri to decode path ngx.req.set_uri(ngx.unescape_uri(uri)); } } proxy_pass ....; 软件包(这是Yarn v2的一部分)

首先,您应该将包添加到您的项目中:
@yarnpkg/pnpify

然后,您可以通过以下方式在VS Code中启用PnP支持:
yarn add -D @yarnpkg/pnpify
这将生成yarn pnpify --sdk并修改您的tssdk,以将.vscode/settings.json内的TypeScript编译器包装器添加为Workspace TypeScript编译器。您应该运行VS Code,打开任何TypeScript文件,然后在窗口的右下角单击TypeScript版本。从下拉菜单中选择tssdk以实际使用Workspace Compiler,其版本后缀为Use Workspace Version

您还可以在此处阅读有关VSCode集成的Yarn v2文档:
https://yarnpkg.com/advanced/editor-sdks#vscode