标签: vscode-jsconfig

如何修复“找不到文件'.../node_modules/dotenv/types'。” 来自 jsconfig.json 的错误?

VSCode 显示 jsconfig.json 错误:“找不到文件‘.../node_modules/dotenv/types’。”

似乎在寻找 dotenv 的打字稿定义,但我没有使用打字稿或 dotenv(除了在导入的包中)。并且有一个node_modules/dotenv/types文件夹。

visual-studio-code dotenv vscode-jsconfig

28
推荐指数
4
解决办法
9804
查看次数

未找到 VSCode jsconfig.json 错误“node_modules/agent-base/dist/src/index”

为什么 VSCode 会显示此错误?

它只是一个 jsconfig.json 文件。

注意:我没有使用 TypeScript。

在此处输入图片说明

visual-studio-code vscode-settings vscode-jsconfig

19
推荐指数
2
解决办法
4605
查看次数

为什么 VSCode 不获取 tsconfig 中的路径别名?

我有一个jsconfig.json,我用一个替换了tsconfig.json。替换后,VSCode 不会获取路径别名并报告导入错误:

例子:

Cannot find module '@Components/Title' or its corresponding type declarations.ts(2307)
Run Code Online (Sandbox Code Playgroud)

jsconfig.json

// https://code.visualstudio.com/docs/languages/jsconfig

{
    "compilerOptions": {
        "baseUrl": ".",
        "paths": {
            "@Components/*": ["./src/components/*"],
            "@Modules/*": ["./src/modules/*"],
            "@Styles/*": ["./src/styles/*"],
            "@Content/*": ["./src/content/*"],
            "@Apps/*": ["./src/apps/*"]
        }
    },
    //Add any build/compiled folders here to stop vscode searching those
    "exclude": ["node_modules", "build"]
}
Run Code Online (Sandbox Code Playgroud)

tsconfig.json

// https://code.visualstudio.com/docs/languages/jsconfig
{
    "compilerOptions": {
        "baseUrl": ".",
        "paths": {
            "@Components/*": ["./src/components/*"],
            "@Modules/*": ["./src/modules/*"],
            "@Styles/*": ["./src/styles/*"],
            "@Content/*": ["./src/content/*"],
            "@Apps/*": ["./src/apps/*"]
        },
        "target": "es5",
        "lib": ["dom", "dom.iterable", "esnext"],
        "allowJs": …
Run Code Online (Sandbox Code Playgroud)

typescript tsconfig visual-studio-code vscode-jsconfig

17
推荐指数
1
解决办法
2万
查看次数

jsconfig.json gives ts errors

I am having jsconfig.json in my root directory using Nuxt.js project. And I am having an error:

File '/home/mike/Documents/nuxt/node_modules/dotenv/types' not found.
  The file is in the program because:
    Root file specified for compilation
Run Code Online (Sandbox Code Playgroud)

Actually 5 errors in a first line of jsconfig.json: 错误

I don't even use typescript and I didn't set any typescript options while creating Nuxt.js project

jsconfig.json content:

{
  "compilerOptions": {
    "baseUrl": ".",
    "paths": {
      "~/*": ["./*"],
      "@/*": ["./*"],
      "~~/*": ["./*"],
      "@@/*": ["./*"]
    }
  },
  "exclude": ["node_modules", …
Run Code Online (Sandbox Code Playgroud)

vue.js visual-studio-code nuxt.js vscode-jsconfig

9
推荐指数
4
解决办法
3649
查看次数

VScode:如何从 jsconfig 快捷方式中指定的快捷方式路径自动补全 json/scss/image 文件路径

在进行导入时,当我尝试导入 React.jsx组件时,智能感知会建议自动完成名称。但是,当我尝试导入jsonscss文件时,不会有任何建议。

我在我的目录中设置了一组别名webpack.config.js

  resolve: {
    extensions: ['.css', '.js', '.jsx'],
    alias: {
      'src': path.resolve(__dirname + '/src'),
      'data': path.resolve(__dirname + '/src/data'),
      'assets': path.resolve(__dirname + '/src/assets'),
      'images': path.resolve(__dirname + '/src/assets/images'),
      'styles': path.resolve(__dirname + '/src/assets/styles'),
      'components': path.resolve(__dirname + '/src/components'),
      'types': path.resolve(__dirname + '/src/types'),
      'functions': path.resolve(__dirname + '/src/functions'),
      'pages': path.resolve(__dirname + '/src/pages')
    }
  },
Run Code Online (Sandbox Code Playgroud)

因为我希望智能感知自动完成这些路径,所以我创建了一个 jsconfig.json

    {
        "compilerOptions": {
          "jsx": "react",
          "allowSyntheticDefaultImports": true,
          "target": "es6",
          "baseUrl": "./",
          "paths": {
            "src": ["./src"],
            "src/*": ["./src/*"],
            "data": ["./src/data"],
            "data/*": ["./src/data/*"],
            "assets": …
Run Code Online (Sandbox Code Playgroud)

intellisense compiler-options webpack visual-studio-code vscode-jsconfig

5
推荐指数
1
解决办法
1346
查看次数

我的 jsconfig.json 在 React js 中出现错误,显示在 JSON 位置抛出 err Unexpected token }

问题是当我尝试运行yarn start 时出现错误

yarn run v1.22.5$ react-app-rewired start
internal/modules/cjs/loader.js:1052
    throw err;
    ^

SyntaxError: /Users/dariocoronel/Desktop/practices/Gostack/javascript/repo/frontend/front/jsconfig.json: Unexpected token } in JSON at position 85
    at parse (<anonymous>)
    at Object.Module._extensions..json (internal/modules/cjs/loader.js:1049:22)
    at Module.load (internal/modules/cjs/loader.js:879:32)
    at Function.Module._load (internal/modules/cjs/loader.js:724:14)
    at Module.require (internal/modules/cjs/loader.js:903:19)
    at require (internal/modules/cjs/helpers.js:74:18)
    at getModules (/Users/dariocoronel/Desktop/practices/Gostack/javascript/repo/frontend/front/node_modules/react-scripts/config/modules.js:126:14)
    at Object.<anonymous> (/Users/dariocoronel/Desktop/practices/Gostack/javascript/repo/frontend/front/node_modules/react-scripts/config/modules.js:142:18)
    at Module._compile (internal/modules/cjs/loader.js:1015:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1035:10)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
Run Code Online (Sandbox Code Playgroud)

但是当我删除我的 jsconfig.json 然后所有运行都没有问题,然后我在项目中再次创建我的 jsconfig 并放入所有配置,然后我在任何文件中进行更改,重新启动时自动显示没有错误重新启动没有问题并运行所有这些我改变了,但如果我重新启动服务器,再次提示错误,我不想总是这样做,我做错了什么?这是我的代码

{ "compilerOptions": {
"baseUrl": "src",
"paths": {
  "~/*":["*"], …
Run Code Online (Sandbox Code Playgroud)

javascript json reactjs vscode-jsconfig

5
推荐指数
1
解决办法
1972
查看次数

Vue.Js:别名配置

components我正在尝试为我的 Vue.js 项目中的和sub-directories使用创建别名jsconfig.json。但我收到此错误:

jsconfig.json

{
    "compilerOptions": {
        "baseUrl": ".",
        "paths": {
            "@components/*": [
                "./src/components/*"
            ],
        }
    },
    "exclude": [
        "node_modules"
    ]
}
Run Code Online (Sandbox Code Playgroud)

SomeFile.vue

import GuestLayout from '@components/Layouts/GuestLayout';
Run Code Online (Sandbox Code Playgroud)

错误:

ERROR  Failed to compile with 1 error

...

To install it, you can run: npm install --save @components/Layouts/GuestLayout
Run Code Online (Sandbox Code Playgroud)

我尝试着解决这个问题,但似乎没有任何效果。这是找到的最简单的一个https://www.youtube.com/watch?v=U73TDohXmhQ

我在这里做错了什么..?

alias vue.js vscode-jsconfig

5
推荐指数
1
解决办法
6426
查看次数

Visual Studio Code Intellisense 和自动完成 - Vite、JSconfig 和 Aliases - 无法找出正确的组合

在使用 PHPStorm/Webstorm 多年后,刚刚再次开始使用 Visual Studio 代码

我决定进行过渡,只是因为 VSCode 非常轻量级,而且我不想依赖付费服务/在每台计算机上都拥有它,因为 VSCode 几乎无处不在并且免费。

我重新开始

维特+Vue3

现在我遇到了导入 CTRL+单击的几个问题 - 转到参考自动完成

我的 Vite.config 如下 - 启用别名

import { defineConfig } from "vite";
import { fileURLToPath, URL } from "url";
import vue from "@vitejs/plugin-vue";
import path from "path";
// https://vitejs.dev/config/
/// <reference types="vitest" />
export default defineConfig({
    resolve: {
        extensions: [".js", ".json", ".vue", ".scss", ".css"],
        fallback: {
            crypto: path.resolve("crypto-browserify"),
            stream: path.resolve("stream-browserify"),
        },
        alias: {
            "@": fileURLToPath(new URL("./src", import.meta.url)),
            img: path.resolve(__dirname, "./public/img"),
        },
    },
    plugins: [vue()], …
Run Code Online (Sandbox Code Playgroud)

javascript vue.js visual-studio-code vscode-jsconfig vite

4
推荐指数
1
解决办法
6474
查看次数