VSCode: How to run npm scripts from the command pallete? - visual-studio-code

I just recently discovered the npm scripts section in VSCode. Now I'm wondering, is there also a way to run npm scripts from the command pallete?
I wasn't able to find any documentation on this, besides defining and launching build and test tasks. In a few results from Google, people were able to run npm scripts by typing > npm: taskname, but for some reason this won't work for me. I suspect this changed when VSCode natively implemented the script runner.

Related

Unable to use npm in VSCode

I have followed available tutorials and searched around for answers but cannot find them. I have just added the npm package via the extensions tab and restarted the computer. I cannot get npm to be recognized in the terminal:
PS E:\Web Apps> npm
npm : The term 'npm' is not recognized...
Does this have to do with the directory? If so, not sure where to change the directory to.
To use npm on the terminal, you need to install nodejs. See this for window instruction.
You must install NodeJS in your system to access npm.
You can install it from https://nodejs.org/en/download/

Powershell commands/scripts not actually running

I am trying to install Emscripten on my computer, and I have run into trouble getting Emscripten actually installed.
I am using the same commands as can be found on the project webpage, but when I try to run
emsdk install latest
Powershell (which is what I am using, but the basic command prompt is behaving the same way) doesn't do anything at all - it just returns without installing anything.
For reference, I have installed Emscripten on this same computer before, but decided to try and do a fresh install of Emscripten after running emsdk activate latest decided to "stop working" as well (whereas it worked just fine last week) - running the command, Powershell simply returned without actually doing anything.
Any ideas on what to check to see why these commands don't seem to run?
I think I solved it. When running the install command in Powershell ISE, it threw the error "Python was not found but can be installed from the Microsoft Store: https://go.microsoft.com/fwlink?linkID=2082640"
despite me having Python installed. Changing the order of my PATH variables to set my Python install directory above the Winapps directory solved the issue with running the install command.

Working on VS Code and after making a JS file I keep getting these two errors about TypeScript and jsHint

So I saved an external JS file for a project I was working on. And when I did that at the top of my editor I got this error:
2.[jshint] Failed to load jshint library. Please install jshint in your workspace folder using 'npm install jshint' or globally using 'npm install -g jshint' and then press Retry.
What exactly am I supposed to do to fix these errors? I've seen other people post this issue but I don't understand the solutions that people have been giving them. Can anyone walk me through fixing these two issues in plain, easy to understand English?
The first error means that vscode can not find an install of npm. We use npm to install files that power IntelliSense for external modules such as express.
To fix it:
Install node/npm if you have not already: https://nodejs.org/en/download/
Restart VS Code
If you still see this warning message after doing this, take a look at the docs on this. The workaround is to set "typescript.npm" to point to where npm is installed on your computer, for example:
"typescript.npm": "/Users/matb/.nvm/versions/node/v8.9.1/bin/npm"
The second error means that vscode cannot find a copy of the jshint library. As the error messages says, the fix is to use npm to install a copy of jshint in your workspace. From a commandline in your workspace, run:
npm install jshint
For all your workspaces (globally)
npm install -g jshint

WebStorm run npm script in tool window (Protractor)

I would like to be able to run an npm script in the Protractor tool window rather than npm. This is easily doable creating a new Protractor Run/Debug config but I need to add a command line argument which the Run config doesnt currently support.
More specifically I am trying to run
protractor --capabilities.chromeOptions.args=--headless --capabilities.chromeOptions.args=--disable-gpu
Would like to do this without modifying the protractor config file.
Essentially, I want to be able to do this without having to provide multiple config files in my project. One for headless, one without.
There is currently no way to specify cmd options in Protractor run configuration, please follow WEB-25165 for updates

Could not install typings files... in VS Code, with Bash on Ubuntu on Windows

I'm trying to use Visual Studio Code with Bash on Ubuntu on Windows. I have VS Code installed on Windows, but otherwise use Bash exclusively for my JavaScript development workflow.
I have node and npm installed on Bash (via apt-get), however, I do not have node and npm also on Windows to avoid duplication. In my VS Code settings, I have configured the integrated shell to use Bash:
"terminal.integrated.shell.windows": "C:\\windows\\Sysnative\\bash.exe"
The integrated shell works fine, and node and npm are both accessible. However, when I launch VS Code on my project, I get the warning:
Could not install typings files for JavaScript langauge features. Please ensure that NPM is installed or configure 'typescript.npm' in your user settings
I have tried both the following settings, neither of which work:
"typescript.npm": "C:\\windows\\Sysnative\\bash.exe"
"typescript.npm": "C:\\windows\\Sysnative\\bash.exe -c \"npm\""
Is it possible to get VS Code to install typings files via the npm that is installed on Bash?
Try setting “externalTerminal.windowsExec”: “bash” in your settings file to set it as the terminal executable and then restart VS Code