question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

resolving multiple tasks with type npm and same script fails

See original GitHub issue

Issue Type: Bug

Create 2 tasks with “type”: “npm” and same “script”

Expected both tasks to be resolved by their label

  • VsCode will list only one of those tasks when listing available tasks with “Tasks: Run Task”.
  • Depending tasks will fail with “Couldn’t resolve dependent task ‘x’ in workspace folder ‘y’” in the “Tasks” output.

tasks.json:

{
    "version": "2.0.0",
    "tasks": [
        {
            "label": "start_both",
            "type": "shell",
            "dependsOn": [
                "start_nr_1",
                "start_nr_2"
            ],
            "problemMatcher": []
        },
        {
            "label": "start_nr_1",
            "type": "npm",
            "script": "start",
            "problemMatcher": []
        },
        {
            "label": "start_nr_2",
            "type": "npm",
            "script": "start",
            "options": {
                "env": {
                    "SOME": "option"
                }
            },
            "problemMatcher": []
        },
    ]
}

package.json:

{
  "scripts": {
    "start": "echo running 'start' script"
  }
}

VS Code version: Code 1.43.1 (fe22a9645b44368865c0ba92e2fb881ff1afce94, 2020-03-18T07:01:20.184Z) OS version: Windows_NT x64 10.0.19041

System Info
Item Value
CPUs Intel® Core™ i7-4790 CPU @ 3.60GHz (8 x 3592)
GPU Status 2d_canvas: enabled
flash_3d: enabled
flash_stage3d: enabled
flash_stage3d_baseline: enabled
gpu_compositing: enabled
multiple_raster_threads: enabled_on
oop_rasterization: disabled_off
protected_video_decode: unavailable_off
rasterization: enabled
skia_renderer: disabled_off_ok
video_decode: enabled
viz_display_compositor: enabled_on
viz_hit_test_surface_layer: disabled_off_ok
webgl: enabled
webgl2: enabled
Load (avg) undefined
Memory (System) 15.92GB (8.47GB free)
Process Argv
Screen Reader no
VM 0%
Extensions: none

Issue Analytics

  • State:open
  • Created 4 years ago
  • Comments:11 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
nelisbijlcommented, Sep 21, 2021

Workaround: add a path property and use ‘.’, or ‘./.’ or ‘././.’ etc.

2reactions
GordonSmithcommented, Jul 23, 2020

@alexr00 I just hit this today as well, in my situation both script calls had different working directories:

		{
			"label": "server tsc watch",
			"type": "npm",
			"script": "compile-watch",
			"options": {
				"cwd": "web/server"
			},
			"problemMatcher": [
				"$tsc-watch"
			],
			"presentation": {
				"group": "group-build"
			}
		},
		{
			"label": "client tsc watch",
			"type": "npm",
			"script": "compile-watch",
			"options": {
				"cwd": "web/client"
			},
			"problemMatcher": [
				"$tsc-watch"
			],
			"presentation": {
				"group": "group-build"
			}
		},

In my case I don’t really have ownership of the web/client and web/server package.json files, so renaming or adding script sections is not an option…

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to solve npm install error “npm ERR! code 1”
When I try to run the npm install command in an older project, I faced the same issues and I resolved it by...
Read more >
Common errors | npm Docs
Some strange issues can be resolved by simply running npm cache clean and trying again. If you are having trouble with npm install...
Read more >
npm-run-all
A CLI tool to run multiple npm-scripts in parallel or sequential. ⤴️ Motivation. Simplify. The official npm run-script command cannot run ...
Read more >
workerpool - npm
A worker executes one task at a time, and once finished, ... What this means is that all I/O code that you write...
Read more >
npx - npm Docs
This command allows you to run an arbitrary command from an npm package (either one installed locally, or fetched remotely), in a similar...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found