Trying to debug an NPM script from within Webstorm. The application runs through the NPM scripts, but when debugging the script it always crashes. I know that there is the flag $NODE_DEBUG_OPTION, but adding that doesn't seem to work.
Script:
"dev": "npm run dev:server & npm run build:client:watch",
"dev:server": "npm run build:server:watch & nodemon --harmony lib/server",
"build:client:watch": "WEBPACK_DEV=true NODE_ENV=development STACK=local node lib/server/webpack",
"build:server:watch": "npm run transpile:watch -- -d lib/common src/common & npm run transpile:watch -- -d lib/server src/server",
"transpile": "BABEL_ENV=node babel",
"transpile:watch": "npm run transpile -- --watch",
According to Webstorm: To debug the "dev" script, make sure the $NODE_DEBUG_OPTION string is specified as the first argument for the node command you'd like to debug. For example: { "start": "node $NODE_DEBUG_OPTION server.js" }
But even when adding this in different places it will still give me an error. Any suggestions?
For anyone reading this in 2020, you just need to right-click the script in the NPM panel and select "Debug ".
You can then set breakpoints in the script and debug in the Debug panel panes, Debugger, Console, etc..
To re-run the script, click the bug icon in the Debug panel.
Probably you are using node8, where this will not work because in node 8 V8 debugger API had been superseded by the V8 inspector API. For more info look at this issue, In previous versions of nodejs this works. For node 8 you should check the WebStorm site, they have information about how to work with the new inspector protocol https://www.jetbrains.com/help/webstorm/run-debug-configuration-node-js.html?search=node
Related
Someone shared with me the code of an application, now I am trying to study it, understand the code before moving on to the next stage of improving it. Funny that the developer is missing in action and he didn't document anything.
Now, launching the app only has been a problem and I notice the error is coming from package.json file. This is the section with the code error:
"scripts": {
"start": "PORT=3333 bash -c 'node scripts/start.js'",
"build": "node scripts/build.js",
"test": "node scripts/test.js --env=jsdom"
},
Now I am running this app on VS CODE on windows 10. I understand on windows you don't have to declare the port at all on that start line but I am wondering how can I rewrite the start line so that to have it working. Any ideas will be highly appreciated.
The Linux shell command
PORT=3333 bash -c 'node scripts/start.js'
starts a new bash process with the environment variable PORT set to 3333, cf. e.g. How do I set an environment variable on the command line.
For cross-pltform compatibility, you can use the cross-env library. (Note however that it's only in maintainance mode.) You can probably use this:
cross-env PORT=3333 node scripts/start.js
I've installed cypress framework on my project.
I already have multiple viewports tests running successively on my app.
Is it possible to automate cross browser testing, so I don't have to select a browser extension to run my test on?
Thanks in advance! :-)
Yes, it is possible. In this case, there can be scenarios that you can run concurrently and there can be scenarios you need to run sequentially. I'll add the solution which I found for both problems.
For this, we need the package.json file. ( If you don't have it do an npm init ) and it will guide you through making the pachage.json
Then let's say we have two test files 1 can be run concurrently, and the other one should not be executed concurrently. let's name them as concurrently.js and sequentially.js
To run the tests sequentially ad your cypress command inside the scripts JSON object.
Ex:
"scripts": {
"cy:sequence:chrome": "cypress run --browser chrome --spec **/sequentially.js",
"cy:sequence:firefox": "cypress run --browser firefox --spec **/sequentially.js",
}
Now you just need to run npm run command to sequence execution, in this case, it will be
npm run cy:sequence:chrome && npm run cy:sequence:firefox
Then if you need concurrent execution, we need to add an npm package [concurently][1]
You can install it with npm i concurrently
Now like we did before we need to add the concurrently.js execution commands to scripts. Here we are using the concurrently package notations to add it. ( check the above URL )
so our final scripts package looks like,
"scripts": {
"cy.concurent:run" : "concurrently \"cypress run --browser chrome --spec **/concurrently.js\" \"cypress run --browser firefox --spec **/concurrently.js\"",
"cy:sequence:chrome": "cypress run --browser chrome --spec **/sequentially.js",
"cy:sequence:firefox": "cypress run --browser firefox --spec **/sequentially.js",
}
if the above addition is not clear, we need to add the commands as quotes with concurrently word being the first word. it should be like
"concurrently "command1" "command2" "
Now if you need to run the tests concurrently in multiple browsers, you just need to run
npm run cy.concurent:run
My only doubt is about the reporting, you might need to add an additional config to save browser-specific videos and reports. If not it might save the data of last execution.
Hope this helps,
Cheers.
[1]: https://www.npmjs.com/package/concurrently
I'm running a node.js application and I installed nodemon.
Unfortunately, I installed it from the CMD on Windows (I keep having problems installing new packages from VS, as it doesn't update the PATH). So once I installed it from CMD, I run a command using nodemom, then Windows asked me what tool to use. I had a few choices, among them VS, but I pressed Windows Bash Script...since then even though I run nodemom from VS terminal, I got the same error as attached again and again.
I have tried to disable WBS, but I didnt find the exact Enable/Disable settings in the registry.
I tried this too: https://answers.microsoft.com/en-us/windows/forum/windows_vista-windows_programs/microsoft-jscript-error-800a03ea/e8723445-77ea-4b13-b13e-afde15f22bfb
enter image description here
I have checked the PATH and seems correct both on the user and system env variables are pointing to: ...npm\node_modules\nodemon\bin\
What else can I do?
Thanks in advance!
When I was trying to run a simple node.js express app I saw the same error message when I had the following code in my package.json:
{
...
"start": "nodemon --exec src/index.js",
...
}
Then Windows was also asking me which program I want to use to execute it.
The fix for me was to set the correct interpreter (in my case node).
{
...
"start": "nodemon --exec node src/index.js",
...
}
if you use window and babel to compile then you can try:
{
...
"start": "nodemon --exec ./node_modules/.bin/babel-node ./src/index.js",
...
}
I am new to React and attempting to use npm test.
From the docs, it is my understanding that every time npm test runs, it starts the watcher. The watcher is supposed to display a list of commands titled "Watch Usage". This includes commands such as a, f and q.
When I run npm test, watcher appears to work because it runs the tests and reruns them if I save a file.
However, it does not display the "Watch Usage" list and if I type any of the "Watch Usage" commands, nothing happens.
How can I enable the "Watch Usage" commands?
I was attempting to run this command in Git Bash. I have not found a solution to make it work in Git Bash.
However, you can instead run the command in cmd.exe and it will work properly.
The Jest VSCode extension can also be helpful.
There is a problem with running Jest inside Git Bash on Windows. The terminal codes for updating the screen are not correctly handled, and I've been unable to find a reason or fix for this searching Google.
If you run npm test from a DOS prompt, then it seems to work fine, but if you run npm test from a Git Bash prompt the progress feedback from Jest is missing.
You can enable colors by running npm run test -- --colors which gets Jest to output the color status for tests in Git Bash, but strangely the colors are working but the progress is still not shown.
The only successful work around that I've found is running Jest from inside winpty if you're using Git Bash.
winpty npm.cmd test
So what I do is add an alternative npm script to my package.json file for running on Git Bash inside Windows.
"wintest": "winpty npm.cmd run test",
Then you can just run that instead.
npm run wintest
It's not a perfect solution, but at least you can see the progress correctly.
You can activate watch mode, modify your package.json:
"scripts": {
"test": "jest --watch",
}
run npm test
I'm having trouble installing Selenium and I'm completely lost
I followed this documentation by the letter and looked around the site and the web for a while now and came to a dead end. Like I said in the title I'm using Chrome and Javascript for this.
[Documentation]http://selenium.googlecode.com/git/docs/api/javascript/index.html
So true with the documentation, the first thing I did was installing the "selenium-webdriver" which I opened up cmd and typed "npm install selenium-webdriver". It responded with saying what directory it installed and the version it installed which was 2.42.1.
After this I installed the ChromeDriver 2.10 from their home download page. After this I unziped the file and moved chromedriver.exe to "node_modules\selenium-webdriver\ChromeDriver" and added it to my systems environmental variables.
So then the next step was to test it, so I copy pasted "npm test selenium-webdriver" into the cmd and got this following error. [Error]http://imgur.com/xIYE3oa I also tried running ChromeDriver after I kept running into this error and tried it again to get the same result. It doesn't tell me anything other then...
Starting ChromeDriver on port 9515
Only local connections are allowed.
Thank you in advance.
First, make sure that you have Mocha installed by running npm install mocha.
You will then want to edit the "scripts" section of the package.json file for selenium-webdriver to match the following:
"scripts": {
"test": "mocha -R list --recursive test"
},
After completing those two steps, you should be able to run your tests with the npm test selenium-webdriver command.