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.

Add arguments property to npm tasks

See original GitHub issue

Does this issue occur when all extensions are disabled?: Yes

  • VS Code Version: 1.63.2
  • OS Version: Windows 11 (10.0.22000.376)

This has been reported before (#128569), but that issue is locked as “not reproducible”. The default Office.js add-ins created using Yeoman generator create several launch configurations. The one for Microsoft Word looks like this:

{
  "name": "Word Desktop (Edge Chromium)",
  "type": "pwa-msedge",
  "request": "attach",
  "useWebView": true,
  "port": 9229,
  "timeout": 600000,
  "webRoot": "${workspaceRoot}",
  "preLaunchTask": "Debug: Word Desktop",
  "postDebugTask": "Stop Debug"
},

preLaunchTask refers to an entry in tasks.json that is defined like this:

{
  "label": "Debug: Word Desktop",
  "type": "npm",
  "script": "start:desktop -- --app word",
  "presentation": {
    "clear": true,
    "panel": "dedicated",
  },
  "problemMatcher": []
},

start:desktop is defined in package.json:

"start:desktop": "office-addin-debugging start manifest.xml desktop",

Trying to launch this configuration, I see the following error:

> Executing task: npm run "start:desktop -- -- app word" <

npm ERR! Missing script: "start:desktop -- -- app word"
npm ERR!
npm ERR! To see a list of scripts, run:
npm ERR!   npm run

It is basically the npm run tasks with command-line argument, which fails saying that it can’t locate the script. Interestingly, running the task directly from the terminal launches it successfully:

$ npm run start:desktop -- --app word

> office-addin-taskpane@0.0.1 start:desktop
> office-addin-debugging start manifest.xml desktop "--app" "word"

Debugging is being started...
App type: desktop
Enabled debugging for add-in 216e8727-a1f1-4fad-9421-a768af6ab77c.
Starting the dev server... (webpack serve --mode development)
The dev server is running on port 3000. Process id: 19976
Sideloading the Office Add-in...
Debugging started.

From this, I conclude that this has got something to do with how arguments are being handled/passed by the task.

Steps to Reproduce:

  1. Install yeoman and office-generator (npm install -g yo generator-office)
  2. Run yo office in an empty folder. Choose Typescript, Word and Task Pane Project options.
  3. Select Word Desktop (Edge Chromium) debug configuration and start debugging. There you go!

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:3
  • Comments:13 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
alexr00commented, Jul 1, 2022

@meganrogge IIRC this would be for adding args that would be passed to the npm command (added in the npm extension), not to the shell.

0reactions
meganroggecommented, Sep 1, 2022

@gthaker the shell workaround should work bc as you mentioned, running it directly in the terminal works and that’s what happens w shell tasks

Read more comments on GitHub >

github_iconTop Results From Across the Web

Sending command line arguments to npm script - Stack Overflow
Just wrap the npm script with a shell interpreter (e.g. sh ) call and pass the arguments as usual. The only exception is...
Read more >
Solved: How to PROPERLY pass arguments to npm script
The simplest way to pass arguments to an npm script is to prepend the arguments to the argument parser called npm_config_ and attach...
Read more >
Three Things You Didn't Know You Could Do with npm Scripts
Argument passing and parsing. So far we covered how to create scripts, which environment variables are set and how to call the scripts....
Read more >
Handling Command-line Arguments in NPM Scripts
The -- notation tells your script to pass the parameters to the current command invoked by NPM. From the NPM docs: "NPM will...
Read more >
scripts - npm Docs
The "scripts" property of your package.json file supports a number of built-in scripts and their preset life cycle events as well as arbitrary...
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