Adding library to node js project developed using Visual studio IDE - node.js

I have started to learn node js. I am using Visual Studio 2015 as IDE for working on Node JS. What are the steps to include a node js library to the node js project on Visual studio 2015 IDE? Normally I install libraries using
npm install library-name
I searched for the node js console window but it is not plugged in to the IDE.

Download the file and then just copy/paste the *.js file in your project and take a reference of it in your design page *.aspx (for ASP.NET) or *.cshtml (for ASP.NET MVC) saying
<script src="~/filename.js"></script>

Related

Visual Studio Installer is not installing node.js

In Visual Studio Installer, I selected the Node.js development option. It runs successfully. But, if I try to run cmd node -v. It tells me node does not exist.
I tried a few other things including uninstalling and reinstalling the Node.js development option in VS Installer. Plus installing the latest version of node from the website.
However, when I try to run the pre-packed Angular solution that comes with VS 2017 I have issues. The solution will not even start.
The best I have been able to do is install Node 6.10.3. Once I do that, the web site comes up. But, I get a JavaScript error in the vendor.js file. I am able to continue but I get this error when I try navigate to another menu item. Plus the Hot Module Replacement does not seem to be working. (It does not automatically recompile my TypeScript file if I made a change).
I think the key is getting the Node.js development option installed correctly since I am able to run the pre-packed Angular solution on another PC and the Hot Module Replacement works fine.
Please let me know if anyone has any ideas on how to resolve.
I had a similar, if not the same, issue. Check the Visual Studio installation directory (2017 Professional in this case) for Node:
C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\Microsoft\VisualStudio\NodeJs
If the executable is there, add the directory to your PATH.

npm install bcrypt on Windows Server 2012

I'm getting this error when trying to install my node modules for my node server.
MSBUILD : error MSB3428: Could not load the Visual C++ component "VCBuild.exe".
To fix this, 1) install the .NET Framework 2.0 SDK,
2) install Microsoft Visual Studio 2005 or
3) add the location of the component to the system path if it is installed elsewhere.
[C:\inetpub\wwwroot\PearsonRealty- API\node_modules\bcrypt\build\binding.sln]
I've tried to install the .NET Framework 2.0 SDK, but it just exits out and never runs. I can't install Microsoft Visual Studio since I'm on an AWS EC2 instance and I wouldn't have enough space for it. Any help would be awesome, thanks.
You do need to install either VCExpress (preferrably at least 2015) or you can try the experimental VC Build Tools solution which is a smaller install than full-blown VCExpress. Otherwise, if you have one, you can try building on a local Windows machine first and then uploading the compiled addon directory to AWS.

Creating an Electron app using Visual Studio (not VSCode) w/ Node.js tools

I'm trying to use Visual Studio (not VSCode) to create a simple Electron app. I'm doing so via the Node.js tools for Visual Studio (v1.1) extension. I'm using the basic quick start app which works fine if I launch via npm start, but if I launch via Visual Studio, I get the following error on start up:
'Cannot find module 'electron' on the first line:
const electron = require('electron');
Can I tell Visual Studio to launch the Electron app first before starting it's node.js debugger? Has anyone else gotten this set up to work at all?
This is possible:
Create a blank Node.js JavaScript console app in Visual Studio. You need a recent version of node installed I think: I have 12.18.3. I'm using VS 2019 Community.
Add a dependencies section to the package.json that's created and reference electron. I referenced 11.0.1 as below:
"dependencies": { "electron": "11.0.1" },
This puts an entry in Solution Explorer under npm, so to actually
install it you can right-click/install npm package (or fire up a
command prompt and do npm install).
Copy the code from the electron-quick-start on GitHub: create index.html AND preload.js files in your Visual Studio project, and paste the code from GitHub into them. Also paste the quick start main.js contents into app.js. There's no need to rename it.
Go to properties of the console app project file. Where it says 'Node exe path:' put the path to electron.exe that was installed, which is in subfolder node_modules\electron\dist\electron.exe.
Put a breakpoint on the first line of createWindow in your app.js.
Start in debug. It should break at the breakpoint and if you continue it will show the basic electron app. This is an Electron window with a message in it: e.g. 'Hello World! We are using Node.js 12.18.3, Chromium 87.0.4280.60, and Electron 11.0.1.'
This is all well and good, but how useful it is depends on what you really want Visual Studio to do for you. It will only break on the main thread, although you can debug the renderer threads using the Chrome dev tools as usual. I find the node tools apps a little limiting. Maybe one of the other project types would be better.
This answer was updated November 2020, and previous answers removed. Note that as usual in npm world things do tend to break over time: please make a comment if things aren't working for you.

Node.js error (could not find) while creating Hybrid app in visual studio 2013

I have done fresh installation of Visual Studio 2013 - update 3 and have installed Visual studio 2013 MDA (Multi Device Application), and also have installed setup for Node js..
But when I create New Hybrid - Application project it shows me an error of "Node.js cannot be found"
Please help me..
You need to have NodeJS installed on your system.
Get the installer from this page: http://nodejs.org/download/
After installation you should also check if node command is usable the command line (cmd).
If it's not available you will need to manually add NodeJS to your path.

How do I debug an AngularJS app in Visual Studio 2013 using Grunt?

I am currently trying to debug an AngularJS app I'm writing using Visual Studio 2013.
I have the recently released Node.js Tools installed.
The app has been scaffolded using Yeoman/Bower/Grunt and uses the commandline grunt serve command to package and start the localhost webserver.
How do I enable debugging from Visual Studio 2013? Do I have to attach to process, or can I hook it up to the trusty F5 in vs2013, or is it even possible at all?
There is a Visual Studio extension which enables Grunt integration:
Grunt Launcher
It adds a right click menu with options to launch Grunt, Gulp and Bower commands. When right clicking on a gruntfile you will see a new submenu listing all your options.
There is also an Angular.js template:
Angular.js SPA Template
There are also more advanced solutions:
Building with nodeJS Tools for Visual Studio
ASP.net SPA Solution Template
KarmaVs
How Can I Benefit from Grunt for my Visual Studio Based Web Development
Grunt your ASP.net Builds
Creating a Software Development Kit

Resources