Visual Studio 2015 Node.js tools npm version - node.js

I would like to use the latest npm within Visual Studio 2015. I've installed Joyent Node from the Visual Studio installer. I understand one can install Node.js seperately but we seem to have issues with that so we are trying to do things the "Microsoft Way". I have also installed the Node.js Tools 1.1 for Visual Studio 2015. Within the node.js interactive window within Visual Studio, running .npm gives me the following:
Specify configs in the ini-formatted file:
C:\Users\MyUsername\.npmrc
or on the command line via: npm <command> --key value
Config info can be viewed via: npm help config
npm#2.7.4 C:\Program Files (x86)\nodejs\node_modules\npm
successfully completed
However, if I use the "Node.js command prompt" and run:
npm -g install npm
It updates npm and running npm command I get the following:
Specify configs in the ini-formatted file:
C:\Users\MyUsername\.npmrc
or on the command line via: npm <command> --key value
Config info can be viewed via: npm help config
npm#3.8.0 C:\Users\MyUsername\AppData\Roaming\npm\node_modules\npm
If I got back to Visual Studio 2015 Node.js Interactive Window and run .npm, I see the version hasn't changed, even with a VS restart. However, I had a long filename issue as reported by other users and not had the issue so I believe that npm 3.8.0 is actually being used but I can't be sure. How can I get Visual Studio 2015 to use the latest npm so I can avoid the long file name problem? Does the Node.js Interactive Window have any relevance here?
Thanks!

Go to Tools -> Options -> Projects and Solutions -> External Web Tools and add path to your node install. Then move it up in the list of dependencies.

Running npm-windows-upgrade within the Node.js command prompt and adding it with the path option with the path output in Visual Studio 2015 (above) fixed it for me.
http://www.triplet.fi/blog/npm-3-will-bring-brighter-future-for-windows-users/
https://github.com/felixrieseberg/npm-windows-upgrade

Related

Error while installing quick.db in discord.js

This is my error. I constantly keep getting this error while trying to npm install quick.db
I am using Visual Studio Code, Node version 17.0.0, discord.js version 13.3.1, please help me, any help would be appreciated.
See the installation section of quick.db
Troubleshooting quick.db/better-sqlite3 installation
Make sure you're using nodejs v10.20.1 or later
Make sure you have node-gyp globally installed, including all of its dependencies. On Windows you may need to configure some things manually. Use npm ls node-gyp to make sure none of your local packages installed an outdated version of node-gyp that is used over the global one.
If you're using Electron, try running electron-rebuild
If you're using Windows, follow these steps. Do them in this order, and don't skip steps.
Install the latest of node 10, 12, or 14.
Install latest Visual Studio Community and Desktop Development with C++ extension.
Install latest Python.
Run following commands:
npm config set msvs_version 2019
npm config set msbuild_path "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin\MSBuild.exe"
Run npm install quick.db

Uninstall npm without using npm - is it possible?

I was manually updating node and npm. I am using them from Visual Studio only. Typing any npm command e.g.
npm --version
causes the process to hang and CPU consumption goes max. So I cannot uninstall or reinstall npm with npm commands. Node seems to work fine. I am using Node version 6.3.1 and it responds normally to
node --version
Calling
where node
gives only one result.
What I have done so far:
Upgraded Node.js outside VS2015 using command prompt.
Uninstalled Node together with npm from command prompt.
Deleted Node program folder and all subfolders
Uninstalled Visual Studio 2015
Installed VS 2017 RC.
Even after this last step, the behavior of npm is the same - it hangs. Visual Studio refuses to build at all.
I hope my problems will be solved when npm starts to work again. So I figure next to try is to uninstall npm alone followed by a reinstall. How can I do that without using npm?
Use the following process:
Delete %appdata%\npm and %appdata%\npm-cache.
Edit your PATH and remove everything that references npm (to do so, hit "Start" and search for env).
Reinstall Node, then install this tool - and only use this tool to upgrade npm, do not attempt to run npm install npm.
References
Microsoft NodeJS Guidelines

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.

npm install for some packages (sqlite3, socket.io) fail with error MSB8020 on Windows 7

When trying to install some node.js packages (sqlite3 and socket.io in particular) using npm install socket.io on my Windows 7 machine with Visual Studio 2012 (and not 2010) I had some failures that looked like this:
C:\Program Files
(x86)\MSBuild\Microsoft.Cpp\v4.0\V110\Microsoft.Cpp.Platform.targets(35,5):
error MSB8020: The builds tools for Visual Studio 2010 (Platform
Toolset = 'v100') cannot be found. To build using the v100 build
tools, either click the Project menu or right-click the solution, and
then select "Update VC++ Projects...". Install Visual Studio 2010 to
build using the Visual Studio 2010 build tools.
To get around this on my machine I did this command to install the package:
npm install socket.io --msvs_version=2012
I found the answer here when having the problem with installing sqlite3 and it worked with socket.io as well.
These might be more permanent solutions to fix the problem:
Install Visual Studio 2010
Updating the npm internal copy to a newer version of node-gyp as described here and here (probably the better option although I didn't get it working but didn't try for too long)
Another option is to change config instead of specifying msvs_version every time:
npm config set msvs_version 2012
I have both Visual Studio Express 2013 and Visual Studio Community 2015 installed.
I was getting
C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V120\Microsoft.Cpp.Platform.targets(64,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 "Upgrade Solution...". [G:\work\cinema\node_modules\engine.io\node_modules\bufferutil\build\bufferutil.vcxproj]
The reason was that the latest Node.js for Windows downloaded from https://nodejs.org contains an old npm v2 (and old node-gyp inside that npm v2).
I had to update Node.js'es internal npm (which also updated node-gyp):
(open console as an administrator)
cd "C:\Program Files\nodejs"
npm install npm#latest
npm config set msvs_version 2013
Now it works (seems that it's using VS 2013 for the time being)
TL;DR
If you DON'T want node-gyp to depend on your installed version of Visual Studio (or don't have VS installed), install windows-build-tools (see below). This will eliminate both the error and should avoid future issues when upgrading your installed version of Visual Studio.
If you DO want node-gyp to depend on your installed version of Visual Studio, then npm config set msvs_version 2015, substitute your version tag in place of 2015. Valid versions tags are: 2015,2014,2013,110,100
Fixing using windows-build-tools
Per the node-gyp installation instructions, you can also do
npm install --global --production windows-build-tools from an ELEVATED command shell
This will install the strictly the Microsoft Visual C++ Build Tools (this will be used in place of Visual Studio for compilation) required by node-gyp, and appropriately set msvs_version to the version just installed.
After installing, you should check that the msvs_version set by windows-build-tools has not been overridden. When executing npm config list, msvs_version should appear under ; globalconfig C:\Users\Username\AppData\Roaming\npm\etc\npmrc; if it does not, the value set by windows-build-tools has been overridden and the overridden value should be deleted. npm config delete msvs_version should delete the overridden value and the one set by the build tools should appear under the global config section.

Resources