Are Linux node modules different from the Windows ones? - node.js

I used the Windows 10 bash subsystem to run a React app. When I installed the node modules and ran the app from the bash all worked fine, but when I tried running it from windows terminal (having installed all the global packages and using the same node version) I got 'react-scripts' is not recognized as an internal or external command
When I removed node_modules and reinstalled them through Windows terminal, all worked fine. So my question is: are some modules written differently for different platforms? Will it cause errors working from sometimes from bash and sometimes from CMD on Windows?

Related

I installed nodejs on WSL2, but cant call it from windows

I have installed Node 18 on Ubuntu on WSL2 in Windows 11. (plus eslint, which is the main end goal) When I'm in the Ubuntu terminal, everything works fine. I can even eslint my code on the windows file system via /mnt/c/somefolder/... - cool!
When I try to call it from the Windows command prompt, I get "command not found"
C:\Windows>wsl node --version
/bin/bash: line 1: node: command not found
Other standard linux commands work fine, e.g. wsl ls or wsl nano foo.txt work as intended (though the current directory differs)
I'm guessing it's something about a PATH to node, but my Google-fu has failed me for a solution.
EDIT, FIXED (sort of): This seems to be NVM related. When I do a basic install of a single version of node in /usr/bin using Ubuntu apt-get (doing the tricks to get the more recent v18.2 LTS) it all works o.k. I don't need NVM for now...
EDIT 2
I can't get the VSCode (running under windows, with the ESLint extension) to connect to the node and eslint code under WSL. Which might just be impossible. Is it?

Why Node not found when running react-scripts?

Created a default create-react-app project. And tried to run it yarn start. Tried to run it in cmd, powershell.
And getting an error:
my-app/node_modules/.bin/react-scripts: node: not found
This is the problematic line in the script:
node "$basedir/../react-scripts/bin/react-scripts.js" "$#" <-- node not found
I checked my PATH vars and set a high priority for C:\Program Files\nodejs
Reinstalled node.js and installed a different version 12.14
UPDATE:
If I run it in bash it works properly. But still, though need to solve it on other terminals
The problem was I had installed WSL and somehow it was running in that environment and there wasn't Node installed there. So I removed WSL and now it runs okay.

I have installed nodejs on windows how should i use it in WSL?

I am having problem using libraries installed on windows to WSL and vice versa. I don't want to install not just nodejs but other things twice just to use it in WSL and also in normal text editors like VS code, atom, etc.
The complete instruction can be found here set-up-on-wsl
If you are too busy to follow the link, follow these steps in the WSL:
Use curl to install nvm
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.3/install.sh | bash
For installing NodeJs (lts)
nvm install node --lts
You can also install specific node version. Check all commands uses by typing nvm in your terminal.
Done Node has been successfully installed in your WSL, nvm ls will list all the installations.
You can use the Node installed in your WSL for developing. Point to your working directory and use code . to open VSCode. Also, if you want to access your windows directories you can mount them by using /mnt/<dir>
If you face any issues during installation it is better to use the link I have provided above.
Also note that, the Node installed in the WSL can only be used, iff your working directory is in the WSL or is linked with your WSL(by using mnt).

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

Cmmand issue - "ng" command not recognized as internal or external even when is in PATH Environment Variable [duplicate]

This question already has answers here:
ng is not recognized as an internal or external command
(51 answers)
Closed 3 years ago.
For some reason, yesterday, all my commands (ng, npm, node, etc.) were working fine, but at night I cleaned my PC from trash files and all that (my pc has Windows installed), and now it doesn't recognize the ng command, but all the others are OK.
I checked the Environment Variables and its path is there, I checked the path, and it's all right, I re-installed with:
npm install -g angular-cli**
However, nothing happened. I rebooted the computer and all that, but I just can't get ng working again.
I ran into this same snafu when I was trying to install Angular (v4.0) correctly. The way I corrected it, after I incorrectly executed npm install #angular/cli -- which generated a directory called node_modules.
To correctly install angular with npm, remove the directory node_modules, then simply start a new bash shell or simply open a new console or terminal tab, and execute sudo npm install -g #angular/cli. This may prompt you for your machine's password, so be prepared to enter it without being able to see it.
It seems like you were following the Angular weblog's instructions for installing Angular v4. You can do that instead instead just as easily; The key to installing Angular v4 correctly on my machine (besides updating my nodejs installation to the prerequisite latest version), was using sudo with the -g (aka. global) option.
At the end I made it work, I had to uninstall even all my NodeJs, de #angular/cli and the angular-cli, Rebooted my computer and then reinstalling NodeJs latest version and installed Angular with npm install -g #angular/cli#latest and removed from PATH and Environment Variables the old paths and got it running fine!
For me (In Windows) the problem was that the npm path was not saved in the path environment variable. If you browse to
C:\users\yourname\AppData\Roaming\npm
Inside this directory you can see ng (a javascript file) and ng.cmd (the windows command file that executes the javascript file). This path needs to be in your path variable to be able to call ng

Resources