is it possible to learn node.js without access to cmd.exe? - node.js

My company has locked down access to CMD.EXE (not sure why)..
I am futtzing around with Node.JS, installed it via the official Windows installer but found I have 0 access to cmd.exe and now I am wondering if I can even go about learning it with the Node terminal only?
Simple things like node -v do not work in the terminal. You have to actually do process.version.
I want to install express as another example and it does not work either.
npm install -g express-generator
Is there another keyword to use in place of npm when using Node.js Terminal?
Also when the Node.js terminal stops at ... is Ctrl-D the only option to break?

They allow you to run installers, but block access to cmd.exe? That is odd, but there are some more options.
Have you tried Powershell? If cmd.exe is blocked, they might have also blocked Powershell.
Install a third party console. Something like:
console
ConEmu
PowerCmd
Use an IDE with built in support like WebMatrix
Install Node on a remote server that you can SSH into (using Putty or similar tools).
Free AWS Micro Instance
$150 / month free on Azure if you can qualify as a startup.
Cheap hosting with Digital Ocean
Free VPS with 5Jelly (Never used them, can't vouch for quality)
Ask your tech department for access (should probably be #1 :)

When you just double-click on or execute just "node.exe" at a command prompt, you get the REPL, which is an environment that allows you to execute javascript code. It's not a regular command prompt.

Related

npm does not install any package Cannot read property 'version' of null

i'm using node v16.7.0 and npm v7.20.3. I bought new laptop(w10) and installed node but since that(almost a week), i couldn't start any node related project because i can not install any npm package. Whenever i try to 'npm install'
npm install <package>
I get the error:
npm ERR! Cannot read property 'version' of null
I dig into all around web to find a solution for this but i couldn't get one. Can someone help me with this issue this is my first question in Stackoverflow.Also if i use dual boot with Ubuntu or WSL2(Web Subsystem for Linux) will i get less errors with development tools even though i'm into web development nothing to do with kernel. Thanks...
Edit: I had spaces and non English character in my username folder in Windows so i tried changing my username and username folder and it solved my problem.(Note that changing username does not reflect to username folder you have to set extra configuration for that).
The error message means that npm is trying to read the version property of the folder's package.json file but doesn't find the file.
Check that you have a package.json file inside your folder, and see what's the value of the version property.
If you need to create a package.json file out of the box, run npm init and follow the instructions. For more information, view the npm documentation about npm init.
Also, make sure that you've installed Node correctly. It's recommended to use a Node version manager to manage your Node installations.
Also if i use dual boot with Ubuntu or WSL2(Web Subsystem for Linux)
will i get less errors with development tools even though i'm into web
development nothing to do with kernel
Yes, and dual-booting with Ubuntu would be best. Virtual machines can be slow and require additional configurations to improve performance, and a lot of issues are reported on WSL.
Most development tools work natively with Linux and therefore run better on Linux. Ultimately, it depends on what language you're developing with and what environment you're developing for.
In general, Linux will make your development experience much less of a hassle. Information, tutorials, and troubleshooting about those tools is also more easily available for Linux.
One of the best things about switching from Windows to Linux is for package management and the command-line interface. Linux makes it easy and straightforward to run commands, whereas Windows can require additional configurations, other workarounds, and intermediary steps.

Locally installed executable dependencies fail using npm run/yarn run on Windows

I am using a Windows machine as my primary development machine. I usually use WSL for most of my projects, but one of my electron projects requires me to work in the Windows environment. So I've set up node, npm, yarn & git on the Windows side as well. But I am having troubles with locally installed dependencies.
Say, I have added concurrently to my project using yarn add concurrently. Now if I do yarn run concurrently, it fails saying that 'C:\Users\Praneet\Projects\my-project\node_modules\.bin\concurrently' is not recognized as an internal or external command. But if I do yarn run concurrently.cmd, it works. Same thing happens for scripts in package.json. I have to change react-scripts start to react-scripts.cmd start to make it work. But I don't want to do this for every script, because there are other devs working with me who use MacOS. I will be really grateful if someone could help me with this.
Have you tried running these commands using Windows Powershell? It might work.
Another option (the one I use when I must code in a Windows environment) is to use Git Bash: https://gitforwindows.org/
It simulates a BASH for Windows, so the commands you are trying to run should work without the .cmd.

Node.js - "node" command works, but not when through another framework

I have Node.js + NPM installed; I can run node -v in my console and get back the current version.
I have also tried using NVM Windows as a Node.js version manager and can run both node -v and npm -v there as well.
HOWEVER, when trying to use another framework like Gulp or Ionic or whatever, I keep getting the error:
'node' is not recognized as an internal or external command,
operable program or batch file.
node is obviously a cmdlet as I can run node -v.. but somehow my other frameworks are no longer able to find it.
Path is correct and everything looks good.
What am I missing here?
The program ConEmu for windows terminal management wasn't pulling or allowing programs to access the paths through subcalls or something it seems. I tested with CMD and Powershell respectively and both worked as expected.
I couldn't get ConEmu to seemingly pass these path to subroutines.. so I uninstalled it and found an alternative called Cmder that is built on ConEmu and it was able to pick them up just fine.
I don't know specifically if it was just a setting in ConEmu I couldn't find or if I needed to manually add these--but happy knowing Cmder just does it automatically.

What to put for NPM scripts when developers are on multiple systems?

I have a web app project, and it uses Mongo, so one of my NPM scripts is "start-mongo-dev": "mongod", for spinning up the Mongo daemon during development.
I used to use OSX, but just got a new computer and run Linux Ubuntu. Now the command to begin the daemon is sudo service mongod start, so it would seem I should change the NPM script to that.
But that is a red flag. What if I go back to the old computer at all? What if I collaborate on this project with someone who uses OSX?
In short, how is one expected to handle developing with multiple OS's?
Ian's solution may be better but one alternative would be to create a bash script inside your project that detects the OS and runs the appropriate command. You can find more info on how to do that here How to detect the OS from a Bash script?
In some packages, I see divisions like this indicated with a :. For example:
"scripts": {
"start-mongo-dev:osx": "mongod",
"start-mongo-dev:ubuntu": "sudo service mongod start"
}
I am not aware of a canonical solution, but that doesn't mean there isn't one. I happen to like this one, though. #opinion

PhpStorm terminal npm (node)

I've just recently started using gulp.js in my projects and I've been trying to learn and use terminal a lot more.
When I run npm commands from the mac terminal default console everything works great however when I run the same commands in PhpStorm the command is not found.
I've followed PhpStorm's guides on installing and integrating the NodeJS plugin etc but I cant seem to get any of the commands to work through it even though its in my usr/local/bin and was installed globally etc.
When I SSH to vagrant though I can use the npm commands etc. Would anyone happen to be able to suggest anything?
This one is quite old but I came across the same problem.
What I did was enter the terminal settings under tools > terminal, go to Application Settings, and change the Shell path to the one you need.
Click the ... button and select the one that suits you.

Resources