Angular/Visual Studio: "ng is needed... npm is needed" - node.js

Using: Windows 10, Visual Studio 2022 17.1.0 (soon to be updated).
I come from the age when I would just copy the JavaScript files of a library in a subfolder of my website/application, add some <script...> tag to the adequate pages and call it installed...
But right now I'm trying to initiate my first Angular 2+ project. I'm trying to start from "Standalone TypeScript Angular Project" template.
But Visual Studio won't create my project, it writes in red
ng is needed (...)
npm is needed (...)
So I checked how to install ng... I needed npm, I checked how to install npm... I read it's recommended to install it through nvm... so I installed nmv, then npm, then ng ( v16.15.1 )... but Visual Studio still won't create my project and keeps requiring npm and ng.
What am I missing?
(I tried searching the Internet but mostly found a bunch of unrelated references and dead links.)
Here are the precise things I ran so far:
nvm-setup.exe
(I installed it in a custom folder of D:\ as I want this kind of tools to go there.)
nvm install lts
This installed npm in a subfolder of my customer folder.
npm install -g #angular/cli
This installed ng in a the same folder as npm + a subfolder.
I added '[...]/v16.15.1' (which contains npm.cmd, ng.cmd and node.exe) to the PATH "environment variable", but the problem remains unchanged.
Solved: after previous step, I needed to restart Visual Studio, but as I kept re-launching Visual Studio from Visual Studio Installer, it didn't work as a restart. Effectively closing the Installer and just relaunching Visual Studio refreshed things and it finally worked.

Solved: I needed to add the path that contains npm, ng and node to Windows "user and/or system Environment Variables".
And I also needed to restart Visual Studio (including closing Visual Studio Installer).

Related

Unable to build native packages for node

So Im running an Electron app that has some native modules of one them being a package called better-sqlite3. I run yarn and yarn is able to install all packages without a problem but when it gets to the building steps, everything breaks.
I get a bunch of diffrent node-gyp error outputs of which 2 I have been able to save so I can show here here is the important part of the error output for the first error:
C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\Common7\IDE\VC\VCTargets\Microsoft.Cpp.Platform.targets(67,5): error MSB8020: The build tools for v140 (Platform Toolset = 'v140') cannot be found. To build using the v140 build tools, please install v140 build tools. Alternatively, you may upgrade to the current Visual Studio tools by selecting the Project menu or right-click the solution, and then selecting "Retarget solution". [C:\Users\bepop\Documents\DeveloperData\Clippy\app\node_modules\better-sqlite3\build\deps\action_before_build.vcxproj]
Full error
In terms of this error I've tried doing multiple things such as installing microsoft visual build tools in many diffrent ways such as manually going to their website and downloading the IDE, I've also tried installing the build tools through NPM with:
npm install --global --production windows-build-tools
It always succesfully installs the build tools but still it errors out on me, I've also tried editing the npm config with:npm config set msvs_version 2017
still doesnt work. I have also tried going to the installation of the Visual Studio and manually checking: "VC++ 2017 version 15.7 v14.14 latest v141 tools"
Also nothing.
I do remember at some point I was able to get everything to build normally with Windows 10 and I never had a problem but not anymore. I've been trying to fix this issue by myself for months now and I've just been sticking on working on the project on my macbook where it never has issues building the better-sqlite3 package.
1 more thing I have tried is completely wiping my computer from everything and starting fresh because at some point i had changed so many things that I lost track of what I had installed and what I did not.
If I remove the better-sqlite3 package from the package.json file everything runs smoothly and I am able to run my project normally but I need the better-sqlite3 package. I could use another package but I really shouldnt have to do that, I'd like to get to the bottom of why this i snot building.
Edit:
Updated: I added Microsoft build tools v14.0.23107.0 to my pats variable and now it outputs error:
C:\Users\bepop\Documents\DeveloperData\Clippy\node_modules\integer\build\integer.vcxproj(21,3): error MSB4019: The imported project "C:\Microsoft.Cpp.Default.props" was not found. Confirm that the path in the <Import> declaration is correct, and that the file exists on disk.
Fixed the issue for myself:
Delete node modules folder
Open PowerShell with admin privileges and run in order
npm install --global --production --vs2015 --add-python-to-path windows-build-tools
npm install --global --production --add-python-to-path windows-build-tools node-gyp
Go to ~/.npmrc and make sure these are your settings:
msvs_version=2015
python=python2.7
First remove all the visual studio version installed from your system , and also remove the entries from path and system variable .
and follow the below URL
https://github.com/nodejs/node-gyp#readme
Every thing run fine after removing of better-sqlite3 this package entry from package.json because other packages don't have any native dependency . and this better-sqlite3 is native module after downloading, this module get build using tool node-gpy that will need two things installed on your system i.e. python and visual studio .
So try to follow the above URL steps.
it will definitely work.

Can not find Karma when installed on windows

I installed visual studio 2015.
Then I run the npm.cmd command (which is installed when installing Visual Studio) (in a cmd window which I started as administrator) to install karma with these commands:
"C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\Extensions\Microsoft\Web Tools\External\npm.cmd" install -g karma
"C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\Extensions\Microsoft\Web Tools\External\npm.cmd" install -g karma-cli
I understood that this will install Karma globally, so I can run it from anywhere.
But when I try to run karma (even when I am in the folder I was when I ran the npm commands), I get the 'karma' is not recognized as an internal or external command, operable program or batch file. message.
What am I missing here?
Did not get it to work with the Node version which was installed with Visual Studio.
Node, as installed with Visual Studio, is a sort of, I don't know how to call it, 'side install' or 'embedded install'. It's not the real NodeJs I guess and it's installed in the Visual Studio directories. (I also do knot know how it gets updated and how security updates are made).
I ended up installing the 'normal' NodeJs which worked instantly.
All the paths were setup correct so when I installed NodeJs, I could run npm from every folder and when I ran the Karma installs I could also start the Karma from every location.
So I stopped looking for the solution with the 'with Visual Studio preinstalled version' and ended up working with the 'normal NodeJs'.

Visual studio scaffold nodejs missing all modules?

I used visual studio to create an node express 4 project. However it cannot run and all the entries under npm show (missing). I cannot find the node_modules folder too.
It doesn't install them automatically. Either run npm install from a command window, or right click on the "npm" item in the project structure and do the install that way. I would recommend doing it through the command prompt though, if you are on a 64 bit machine.

Visual Studio Bundled Node Js vs standard alone

I have installed Visual Studio 2015 and it comes with nodejs and npm now. Prior to installing Visual Studio i had installed a 64 bit Nodejs and this is up to date.
When I am trying to add gulp-less dependency to package.json file fails. Having a look at the Bower/NPM outputs I do see an Warning
npm WARN engine hawk#3.1.0: wanted: {"node":">=0.10.32"} (current: {"node":"v0.10.31","npm":"1.4.9"})
I suspect the issues is related to visual-studio being a 32 bit process it load a different version of Node and for unknown release ignores the 64 bit node js. This happens despite the fact I have $(path) varible before "$(DevEnvDir)\EXTENSIONS\MICROSOFT\WEB TOOLS\External" in External Web Tools.
So question is how do I update the Visual Studio version of Node.
Okay got my solution.
1- Removed NPM and node from system -> path
2- Open command prompt with Administrator priviledge and navigate to visual studio install directory
C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\Extensions\Microsoft\Web Tools\External
3- run npm install -g npm
that fixes the problem, also remember to restart visual studio afterwards.

Problems running the ripple emulator on Visual Studio 2013

I am trying to run the ripple emulator on Visual Studio, however I cannot seem to get pass the cannot find module './lib/plugin'error as follows:
C:\Users[user name]\Documents\Visual Studio 2013\Projects\Cordova\Cordova>call "C:\Program Files (x86)\nodejs\"\nodevars.bat
Your environment has been set up for using Node.js 0.10.33 (ia32) and npm.
------ Ensuring correct global installation of package from source package directory: E:\PROGRAM FILES (X86)\VISUAL STUDIO\COMMON7\IDE\EXTENSIONS\FUBXMEK2.O2B\packages\vs-mda
1>MDAVSCLI : error : Cannot find module './lib/plugin'
PS: The previous error I got was cannot find module 'q' however this was resolved by running npm install from CLI.
I am trying to create a Cordova application using Visual Studio. Any ideas how I can resolve the above error?
It seems something went wrong while installing vs-mda, you can try following to re-install:
Close Visual Studio
Open cmd
npm install -g [path to vs-mda example C:\Users[user-name]\AppData\Roaming\npm\node_modules\vs-mda]
npm install -g [path to vs-mda-targets example C:\Users[user-name]\AppData\Roaming\npm\node_modules\vs-mda-targets]
OR
Go to Tools --> Options --> Tools for Apache Cordova --> Cordova Tools --> Clear Cordova Cache
For the second method above (Clear Cordova Data) try running visual studio as administrator if it fails the first time around.

Resources