profile
viewpoint

Ask questionsEnable node typings if file starts with node shebang

<!-- ⚠️⚠️ Do Not Delete This! bug_report_template ⚠️⚠️ --> <!-- Please read our Rules of Conduct: https://opensource.microsoft.com/codeofconduct/ --> <!-- Please search existing issues to avoid creating duplicates. --> <!-- Also please test using the latest insiders build to make sure your issue has not already been fixed: https://code.visualstudio.com/insiders/ -->

<!-- Use Help > Report Issue to prefill these. -->

  • VSCode Version:
  • OS Version:

Steps to Reproduce:

Here is intellisense working correctly for a node script in a project: image

Here is another screenshot showing the support not working for a global script that does have a project:

image

As node.js is a perfectly valid choice for scripting, and has no need for verbose project structures to work, the lack of support is a bug.

System Info

CPUs | Intel(R) Core(TM) i5-6267U CPU @ 2.90GHz (4 x 2900)
-- | --
GPU Status | 2d_canvas: enabledflash_3d: enabledflash_stage3d: enabledflash_stage3d_baseline: enabledgpu_compositing: enabledmetal: disabled_offmultiple_raster_threads: enabled_onoop_rasterization: disabled_offprotected_video_decode: unavailable_offrasterization: enabledskia_renderer: disabled_off_okvideo_decode: enabledviz_display_compositor: enabled_onviz_hit_test_surface_layer: disabled_off_okwebgl: enabledwebgl2: enabled
Load (avg) | 8, 6, 6
Memory (System) | 8.00GB (0.08GB free)
Process Argv |  
Screen Reader | no
VM | 0%



Extension | Author (truncated) | Version
-- | -- | --
better-comments | aar | 2.0.5
interactive-scala | als | 1.2.1
better-toml | bun | 0.3.2
gitignore | cod | 0.6.0
bracket-pair-colorizer-2 | Coe | 0.1.3
scala | dal | 0.0.5
vsc-material-theme | Equ | 32.6.0
vsc-material-theme-icons | equ | 1.1.4
language-julia | jul | 0.15.32
crystal-ide | kof | 0.0.4
dotty | lam | 0.1.16
Lisp | mat | 0.1.10
vscode-docker | ms- | 1.2.0
python | ms- | 2020.5.78807
remote-containers | ms- | 0.117.1
remote-ssh | ms- | 0.51.0
remote-ssh-edit | ms- | 0.51.0
remote-wsl | ms- | 0.44.2
vscode-remote-extensionpack | ms- | 0.20.0
powershell | ms- | 2020.4.0
vscode-paste-image | mus | 1.0.4
gradle-language | nac | 0.2.3
java | red | 0.61.0
datetime | rid | 2.0.1
rust | rus | 0.7.8
scala | sca | 0.3.9
ayu | tea | 0.18.0
vscode-lldb | vad | 1.5.0
vscodeintellicode | Vis | 1.2.7
vscode-java-debug | vsc | 0.26.0
vscode-java-dependency | vsc | 0.10.1
vscode-java-pack | vsc | 0.9.1
vscode-java-test | vsc | 0.22.4
vscode-maven | vsc | 0.21.4
org-mode | vsc | 1.0.0
vim | vsc | 1.14.4
debug | web | 0.24.0
markdown-all-in-one | yzh | 2.8.0

microsoft/TypeScript

Answer questions mjbvz

Similar to https://github.com/microsoft/TypeScript/issues/30902

The issue seems to be that we aren't picking up any signals that these JS files should have node apis enable

As a workaround, you can either npm install @types/node into your workspace or create a jsconfig that explicitly includes the node typings:

{
    "compilerOptions": {
        "module": "commonjs",
        "target": "es2016",
        "jsx": "preserve",
    },
    "exclude": [
        "node_modules",
        "**/node_modules/*"
    ],
    "typeAcquisition": {
        "include": [
            "node"
        ]
    }
}
useful!

Related questions

Why `window.location.reload(true)` is deprecated? hot 8
Cannot export { ... } interface when --isolatedModules is passed hot 3
TS2739: Type is missing the following properties from type hot 3
TSC Strict mode error TS2722: Cannot invoke an object which is possibly 'undefined'. hot 2
This condition will always return 'false' since the types have no overlap. hot 2
Allow extending types referenced through interfaces hot 2
Suppressing "The import path cannot end with a '.ts' extension" error? hot 2
Property 'setState' does not exist on type 'App'.ts(2339) hot 2
Cannot find name 'MediaRecorder'. hot 2
tsc.ps1 cannot be loaded. The file ... is not digitally signed hot 2
error TS1183: An implementation cannot be declared in ambient contexts. hot 2
3.7.2 Promise.all does infers base type of interfaces rather than actual interface hot 1
Skip typechecking; only emit (support `--transpileOnly` in `tsc`, re-open of #4176) hot 1
tsc crash with node OOM hot 1
error TS2688: Cannot find type definition file for...random paths. hot 1
Github User Rank List