Electron command opens file asscociation menu in Windows 10 - node.js

I am new to Windows 10. I am building Screencat app for Windows. But when I run the "npm start" in console, I get the below popup asking for how I want to open the js file.
Is it possible to run electron apps in Windows 10?

For Screencat npm start runs the command electron electron.js. It seems that your OS is not recognising electron as a valid command.
Did you follow the instructions (https://github.com/maxogden/screencat#building-the-app) for Windows completely? In particular, installing C++ and installing and running electron-rebuild.
You will need Visual studio C++ installed so you can build the native modules. Here are instructions for cmd.exe
git clone https://github.com/maxogden/screencat.git
cd screencat
npm install
npm install electron-rebuild
.\node_modules\.bin\electron-rebuild.cmd
npm start

Related

Linking Windows commands inside Windows Subsystem for Linux Ubuntu

I'm doing web development on Windows 10 using Windows Subsystem for Linux with Ubuntu 18.04. Using Node.js and NPM inside Ubuntu and running dev servers and API servers works.
When I am inside WSL I can run commands:
npm i
node app
npm run serve
# etc...
And now there is a new situation. I have a project using Nightmare.js (improved but similar to Phantom.js) which will install Electron headless browser when running npm i. Running npm i inside WSL will install Ubuntu version of Electron and when trying to run nothing will happen, browser will not be open. Which is logical because WSL Ubuntu has no visual environment thus can't open a browser in it.
If I run npm i with PowerShell or CMD (npm that is installed on Windows instead WSL will be used), Windows version of Electron will be installed and I can run it with node app inside PowerShell and it will work as expected, browser opens etc...
This creates and interesting precedent. It looks like I will need to sometimes run my applications with Windows commands. Instead of doing npm i or node app directly in WSL I have to switch to CMD or PowerShell and execute them there, so that windows versions of npm and node are used instead of WSL Ubuntu's. This is not very convenient and I would like to do it all from WSL. For an example of this behavior there is Visual Studio Code from Microsoft. With Remote-WSL add-on installed I can run code command inside WSL Ubuntu and VSCode will open in Windows.
Here is my question: Is there a way to link commands in WSL Ubuntu to Host Windows system just like it is done with VSCode? Ideally I would like to have something like this in my WSL Ubuntu: windows-npm i, windows-node app that will run npm and node on the Host Windows System instead of the same commands on WSL Ubuntu.
There is little to no attention to the issue, so I decided to fix my self. I'm still looking for better/native solution but here is a workaround I came up with.
WSL-Link
Allows WSL users to run any CMD commands on host Windows system from within linux subsystem.
Requirements
Windows 10
WSL
Node.js
NPM
Node and NPM have to be installed both in linux subsystem and on Windows host system.
Install
wsl-link has to be installed separately in subsystem and on Windows host
On subsystem linux:
npm i wsl-link -g
On Windows host:
npm i wsl-link -g
Windows Startup
To run script at startup on windows I use PM2 with supplied daemon script.
Install pm2 and pm2-windows-startup on Windows host:
npm i pm2 pm2-windows-startup -g
Install pm2-startup:
pm2-startup install
Run wsl-link pm2 daemon:
wsl-link-pm2
Save pm2 list of processes
pm2 save
You can now confirm that the wsl-link app is running, with:
pm2 status
Usage
On Windows start server (if not using startup setup with pm2):
wsl-link
Use on subsystem linux (npm -v will be run on host Windows):
wsl-link npm -v
Case
On subsystem linux setup a project (or use existing):
mkdir wsl-link-test
cd wsl-link-test
touch app.js
npm init
app.js:
const Nightmare = require('nightmare');
(async () => {
await Nightmare({
show: true
})
.goto('https://google.com');
})();
Install Windows version of Nightmare.js and run it on Windows.
wsl-link npm i nightmare --save
wsl-link node app
You should see Electron browser open on your Windows host.

Appium version is not displayed when it is installed from GitHub but displayed when installed via nodejs cmd. Should we install in both ways?

I'm new to Appium and started with setting up Appium desktop v 1.11.0 in my windows machine by downloading it from github .I downloaded NodeJS aswell and installed them. When i just navigate to cmd and typed "appium -v" I got the message as
'appium' is not recognized as an internal or external command,
operable program or batch file.
But however when i tried installing appium with "npm install -g appium" in the cmd appium is installed and appium version is displayed when typed "appium -v" as in below screenshot.
appium version displayed after installing appium via cmd
Should we install appium from both cmd and github to work on Appium ?
But i feel like i missed some steps before checking for appium version in cmd after installing appium from github.
Please any one help me with correct installation of appium. Thanks in advance.
Appium server and Appium Desktop are not the same. The one you installed using npm command is appium server.
Appium Desktop is the combination of Appium Server and Appium Inspector. Using appium Desktop you can inspect the elements as well.
You can install both appium server and appium desktop as per your choice.

How to run the Reactjs Web Application in localhost:3000 in windows

I'm a new React Developer, and I'm having a problem in running it to my chrome. I already did the npm install in cmd, and then I npm start by its not starting because of error in cmd. And my OS is Windows 10.
What should I do?
in your package.json file the script define rm command witch is not available in windows that's why you are getting error
insted of rm change it to del
and if there is any UNIX specific command then change it to windows equivalent

How to resolve 'npm should be run outside of the node repl, in your normal shell'

I am new to node.js. I downloaded and install node.js installer from the official site. I have added this installer folder in PATH environment variable and I am able to run programs. But when I try to install some package using npm in node console it shows the error npm should be run outside of the node repl, in your normal shell. I also tried it on a separate console. But it shows command not found though I have added node in the environment variable.
For Windows users, run npm commands from the Command Prompt (cmd.exe), not Node.Js (node.exe). So your "normal shell" is cmd.exe. (I agree this message can be confusing for a Windows, Node newbie.)
By the way, the Node.js Command Prompt is actually just an easy shortcut to cmd.exe.
Below is an example screenshot for installing grunt from cmd.exe:
Do not run the application using node.js icon.
Go to All Programmes->Node.js->Node.js command prompt.
Below is example screen shot.
If you're like me running in a restricted environment without administrative privileges, that means your only way to get node up and running is to grab the executable (node.exe) without using the installer. You also cannot change the path variable which makes it that much more challenging.
Here's what I did (for Windows)
Throw node.exe into its own folder (Downloaded the node.exe stand-alone )
Grab an NPM release zip off of github: https://github.com/npm/npm/releases
Create a folder named: node_modules in the node.exe folder
Extract the NPM zip into the node_modules folder
Make sure the top most folder is named npm (remove any of the versioning on the npm folder name ie: npm-2.12.1 --> npm)
Copy npm.cmd out of the npm/bin folder into the top most folder with node.exe
Open a command prompt to the node.exe directory (shift right-click "Open command window here")
Now you will be able to run your npm installers via:
npm install -g express
Running the installers through npm will now auto install packages where they need to be located (node_modules and the root)
Don't forget you will not be able to set the path variable if you do not have proper permissions. So your best route is to open a command prompt in the node.exe directory (shift right-click "Open command window here")
It's better to use the actual (msi) installer from nodejs.org instead of downloading the node executable only. The installer includes npm and makes it easier to manage your node installation. There is an installer for both 32-bit and 64-bit Windows.
Also a couple of other tidbits:
Installing modules globally doesn't do what you might expect. The only modules you should install globally (the -g flag in npm) are ones that install commands. So to install Express you would just do npm install express and that will install Express to your current working directory. If you were instead looking for the Express project generator (command), you need to do npm install -g express-generator for Express 4.
You can use node anywhere from your command prompt to execute scripts. For example if you have already written a separate script: node foo.js. Or you can open up the REPL (as you've already found out) by just selecting the node.js (start menu) shortcut or by just typing node in a command prompt.
As mscdex said NPM comes with the nodejs msi installed file. I happened to just install the node js installer (standalone). To separately add NPM I followed following step
Download the latest zip file of NPM from here.
Extract it in the same file as that of node js installer.
If you have added the directory containing to node js installer to PATH env variable then now even npm should be a recognized command.
you just open command prompt,
then enter in c:/>('cd../../')
then npm install -g cordova
It's simple. Press the Windows logo on your keyboard. Then, type node.js command prompt in the search bar and run it.
You must get directory right path of program(node.js in program files).
such as
and use "npm install -g phonegap"
Just open Node.js commmand promt as run as administrator

Building syntaxhightlighter with nodejs in windows 7

I need to build Syntaxhighlighter from here: https://github.com/alexgorbatchev/SyntaxHighlighter
I have read these:
https://npmjs.org/doc/faq.html
Getting started with NODE.JS in windows x86
Get started with Node.js in Windows
Installing node packages / dependencies using npm on Windows Server 2008
It seems that installing Nodejs from here http://nodejs.org/download/ should be enough.
Step 3 in the syntaxhighlighter Building instructions says:
3.Then ./node_modules/.bin/bower install to download dependencies
I have this path on my machine:
C:\Program Files (x86)\nodejs\node_modules\npm\bin
and I can see a bower.json in the syntaxhighlighter zip file.
I have googled how to download dependencies for windows, but I cant find anything.
There is a lot of info here:
How do I get started with Node.js
but I think this is not for windows env.
Can you assist?
EDIT:
Ok, seems to work now.
Installed Git-1.8.4-preview20130916.exe and restarted.
Step 8 ok now.
Step 9 gives "grunt not recognized".
Tried
npm install -g grunt-cli
from here: https://github.com/gruntjs/grunt/issues/774
Now I have a pkg folder
Thank you sir
Install NodeJs for Windows per instructions
Install Git for Windows, select option to Add Git to your path.
Open a new command prompt in Windows. Ideally, open as an Administrator. Do not reuse existing command prompts. The path will only be set in a new command prompt properly.
Download the code for the highlighter or use git to clone
If you got the zip file, unzip it
From the command prompt, change the active directory to be the folder of the code you cloned or unzipped
Type npm install -g grunt-cli, then Enter after each of the following...
Type npm install -g bower
Type npm install
Type bower install
Type grunt build
Done.
You have to install git package in this way:
sudo apt-get install git
It's working fine!

Resources