npm global install does not add packages to PATH on Windows 8.1 - windows

When I run npm install -g <package> it installs the packages in my user/AppData/Roaming/npm/npm_modules/ folder. This sub-folder is not in my PATH so if I try to run the package without explicitly calling the entire path the call fails with a '<package>' is not recognized as an internal or external command, operable program or batch file.
What can I do to fix this?
Thanks

I'm using win8.1 and I found that the nodejs installer didn't add the path to global node modules to the system PATH. Just add %AppData%\npm; to the user variable(since %AppData% dir is depending on user) PATH to fix it.
You will need to log out then log back in for the change to your PATH variable to take effect.
SET PATH=%AppData%\npm;%PATH%

You have to run this line SET PATH=pathtonodejs;%PATH% (where pathtonodejs is where you installed nodejs) once the installation for nodejs is complete and it should work.

It turned the problem was a change in behavior of the module I was using.
I'd been following old tutorials for using Express.js. The old tutorials assumed Express would be in my path after installing it globally, but as of Express v4.0 there's a separate Express module you have to install in order to get it in your path

Related

Windows Script Host Error: Invalid character - Code:800A03F6 - Source: Microsoft JScript compilation error

I'm having an issue with Powershell and CMD. When I try to execute Angular CLI commands in CMD like ng --version or ng new projectName, I get this error;
Windows Script Host Error: Invalid character
Code: 800A03F6
Source: Microsoft JScript compilation error
Update:
On Windows .js files are associated to Windows Scripting Host by default, so the script will not be run with Node.
Open a file explorer and find a JavaScript file, open the JavaScript file's properties and then "open with", select the Node.js program file to open that kind of files.
The error should stop after doing this.
This is how I solved it: (on windows 10)
Go to C:\Users\<your_username>\AppData\Roaming\npm\node_modules\#angular\cli\bin
Check for ng.js
Right click on ng.js file and click on "properties" option
You need to open it with node.exe so click on "Change" button go to node js installed directory and
(example: C:\Program Files\nodejs\node.exe)
Select node.exe
Click on OK
It should change the color of ng.js like below:
Now try ng -v and other ng commands
Installing this exact Angular version:
npm -g install #angular/cli#10.3.1
instead of the latest version:
npm -g install #angular/cli
fixed the above error.
I ran into this exact issue after updating to Angular CLI 13. Tried tons of different suggestions from other threads. What is described in the solutions here is essentially what worked for me, but I just want to point out a possible alternative method to applying the fix that doesn't associate all JS files with node.js.
Trying to execute a script from package.json on Windows throws a JScript error
In your windows system environment variables is one variable called PATHEXT. If the value contains .JS;, remove it. Then restart your CMD windows.
make sure you have proper path variable configured as shown below
Go to your system variable settings
path variable snapshot
make sure you have all these mentioned as part of path
C:\Users<userfolder>\AppData\Roaming\npm\node_modules#angular\cli
C:\Users<userfolder>\AppData\Roaming\npm
C:\Program Files\nodejs
make sure you have all these mentioned as part of path C:\Users\AppData\Roaming\npm\node_modules#angular\cli C:\Users\AppData\Roaming\npm C:\Program Files\nodejs
in my case, before npm install -g #angular/cli, the path of my system variable was:
C:\Users\AppData\Roaming\npm\node_modules#angular\cli\bin
I remove \bin and work!!!!!
Remember to fix this for the correct User
Associating .JS files to node.exe is the way to solve this.
BUT after struggling with the same issue, I wanted to add that the file association needs to be done with the same USER that you are working with the Terminal/Shell.
So if you use the Terminal as a Admin, you must login with your Admin Account just to fix the file association.
Cheers

PHPDocumentor - Graphviz 'dot' command not found

I am trying to get PHPDocumentor running on a local XAMPP installation.
Sadly I having a hard time doing it using package managers.
Some basic questions about package managers first:
How do I know where to install a package? For example: I installed PHPDocumentor using Composer. I go to my C:\xampp\htdocs\ and run a command:
composer require "phpdocumentor/phpdocumentor:2.*"
This installs phpdocumentor in a " vendor" folder in xampp\htdocs\
Is this the correct path to install all these packages or is there a default dir to install this?
If I want to uninstall the packages, do I simply delete the "vendor" dir?
After the installation I ran PHPdocumentor and got an error:
Unable to find the dot command of the GraphViz package. Is GraphViz
correctly installed and present in your path?
To resolve this, I tried the following:
Installed the package graph/graphviz while my pointer was in the htdocs-folder and pointed a path to the folders:
C:\xampp\htdocs\vendor\graph\graphviz
...graph\graphviz\src
...graph\graphviz\tests
None of the above solved the problem.
According to this link I have to add the \graphiz\bin directory to path, but there is no "bin" dir?
Can anyone help me out with this?
Best regards,
Abayob
Unable to find the dot command of the GraphViz package. Is GraphViz correctly installed and present in your path?
The steps to resolve this error are:
download zip from https://graphviz.gitlab.io/_pages/Download/Download_windows.html
extract to c:\some\where\graphviz
add c:\some\where\graphviz\bin to your environment variable PATH
run phpdoc
I don't like to have 184MB of usefull stuff on my PC just to run the 'dot' command?
Yes, its a lot of stuff. A more lightweight solution would be nice.

How to install gokogiri on Windows?

I'm trying to install gokogiri on Windows 8 machine, and these are steps that I have done so far :
Download pkg-config_0.26-1_win32.zip from here, unzip/extract, and add the bin folder to path environment variable
Donwload libxml2-2.9.2-win32-x86.7z from here, unzip to a location which path doesn't contain space(s) (otherwise gcc won't be able to find the location). Create new environment variable PKG_CONFIG_PATH, and add libxml's \lib\pkgconfig folder location to the env variable.
Donwload and install tdm64-gcc from here
run the following command (as suggested in the GitHub link above) : go get github.com/moovweb/gokogiri
but then I get this error :
What is the error message complaining about now? If I need to download icnov manually, how then I put it together with libxml2 to work properly?

How to use npm with node.exe?

I have downloaded Windows Binary (.exe) of nodejs from the main page.
How can I install and use npm (Node package manager)?
The current windows installer from nodejs.org as of v0.6.11 (2012-02-20) will install NPM along with NodeJS.
NOTES:
At this point, the 64-bit version is your best bet
The install path for 32-bit node is "Program Files (x86)" in 64-bit windows.
You may also need to add quotes to the path statement in environment variables, this only seems to be in some cases that I've seen.
In Windows, the global install path is actually in your user's profile directory
%USERPROFILE%\AppData\Roaming\npm
%USERPROFILE%\AppData\Roaming\npm-cache
WARNING: If you're doing timed events or other automation as a different user, make sure you run npm install as that user. Some modules/utilities should be installed globally.
INSTALLER BUGS: You may have to create these directories or add the ...\npm directory to your users path yourself.
To change the "global" location for all users to a more appropriate shared global location %ALLUSERSPROFILE%\(npm|npm-cache) (do this as an administrator):
create an [NODE_INSTALL_PATH]\etc\ directory
this is needed before you try npm config --global ... actions
create the global (admin) location(s) for npm modules
C:\ProgramData\npm-cache - npm modules will go here
C:\ProgramData\npm - binary scripts for globally installed modules will go here
C:\ProgramData\npm\node_modules - globally installed modules will go here
set the permissions appropriately
administrators: modify
authenticated users: read/execute
Set global configuration settings (Administrator Command Prompt)
npm config --global set prefix "C:\ProgramData\npm"
npm config --global set cache "C:\ProgramData\npm-cache"
Add C:\ProgramData\npm to your System's Path environment variable
If you want to change your user's "global" location to %LOCALAPPDATA%\(npm|npm-cache) path instead:
Create the necessary directories
C:\Users\YOURNAME\AppData\Local\npm-cache - npm modules will go here
C:\Users\YOURNAME\AppData\Local\npm - binary scripts for installed modules will go here
C:\Users\YOURNAME\AppData\Local\npm\node_modules - globally installed modules will go here
Configure npm
npm config set prefix "C:\Users\YOURNAME\AppData\Local\npm"
npm config set cache "C:\Users\YOURNAME\AppData\Local\npm-cache"
Add the new npm path to your environment's PATH.
setx PATH "%PATH%;C:\Users\YOURNAME\AppData\Local\npm"
For beginners, some of the npm modules I've made the most use of are as follows.
axios - for more complex http posts/gets
isomorphic-fetch - for http(s) post/get requests
node-mailer - smtp client
mssql - interface and driver library for querying MS SQL Server (wraps tedious)
More advanced JS options...
async/await - async functions, supported via babel
For testing, I reach for the following tools...
mocha - testing framework
chai - assertion library, I like chai.expect
sinon - spies and stubs and shims
sinon-chai - extend chai with sinon's assertion tools
babel-istanbul - coverage reports
jest - parallel testing, assertions, mocking, coverage reports in one tool
babel-plugin-rewire - slightly easier for some mocking conditions vs. jest
Web tooling.
webpack - module bundler, package node-style modules for browser usage
babel - convert modern JS (ES2015+) syntax for your deployment environment.
If you build it...
shelljs - shell utilities for node scripts,. I used to use gulp/grunt, but these days will have a scripts directory that's referenced in package.json scripts via npm. You can use gulp tools inside plain scripts.
When Node.js is not installed using the msi installer, npm needs to be setup manually.
setting up npm
First, let's say we have the node.exe file located in the folder c:\nodejs. Now to setup npm-
Download the latest npm release from GitHub (https://github.com/npm/npm/releases)
Create folders c:\nodejs\node_modules and c:\nodejs\node_modules\npm
Unzip the downloaded zip file in c:\nodejs\node_modules\npm folder
Copy npm and npm.cmd files from c:\nodejs\node_modules\npm\bin to c:\nodejs folder
In order to test npm, open cmd.exe change working directory to c:\nodejs and type npm --version. You will see the version of npm if it is setup correctly.
Once setup is done, it can be used to install/uninstall packages locally or globally. For more information on using npm visit https://docs.npmjs.com/.
As the final step you can add node's folder path c:\nodejs to the path environment variable so that you don't have to specify full path when running node.exe and npm at command prompt.
npm can be downloaded (without installation) from here:
http://nodejs.org/dist/npm/
https://github.com/npm/npm/releases
I just installed latest version of node (0.6.12) in Windows 7 using msi (node-v0.6.12.msi).
npm is already shipped with it, no need to include it separately.
I was facing permission issue while running npm (npm install mysql), from the path where my nodejs resided, i.e.
C:\Program Files (x86)\nodejs
Then I followed below steps:
1) Added C:\Program Files (x86)\nodejs\npm in environment variables - Path system variable.
2) went back to only C:\ in command prompt and gave the command - npm install mysql - and voila! it worked..
Hope this helps.
I am running node.js on Windows with npm.
The trick is simply use cygwin. I followed the howto under https://github.com/joyent/node/wiki/Building-node.js-on-Cygwin-(Windows) . But make sure that you use version 0.4.11 of nodejs or npm will fail!
I've just installed 64 bit Node.js v0.12.0 for Windows 8.1 from here.
It's about 8MB and since it's an MSI you just double click to launch. It will automatically set up your environment paths etc.
Then to get the command line it's just [Win-Key]+[S] for search and then enter "node.js" as your search phrase.
Choose the Node.js Command Prompt entry NOT the Node.js entry.
Both will given you a command prompt but only the former will actually work. npm is built into that download so then just npm -whatever at prompt.
Use a Windows Package manager like chocolatey. First install chocolatey as indicated on it's homepage. That should be a breeze
Then, to install Node JS (Install), run the following command from the command line or from PowerShell:
C:> cinst nodejs.install
Here is a guide by #CTS_AE on how to use NPM with standalone node.exe:
https://stackoverflow.com/a/31148216/228508
Download the node.exe stand-alone from nodejs.org
Grab an NPM release zip off of github https://github.com/npm/npm/releases
Create a folder named: node_modules in the same folder as node.exe
Extract the NPM zip into the node_modules folder
Rename the extracted npm folder to npm and remove any versioning ie: npm-3.3.4 –> npm.
Copy npm.cmd out of the /npm/bin/ folder into the root folder with node.exe
I just installed Node.js for the first time and it includes NPM, which can be ran from the Windows cmd. However, make sure that you run it as an administrator. Right click on cmd and choose "run as administrator". This allowed me to call npm commands.
Search all .npmrc file in your system.
Please verify that the path you have given is correct. If not please remove the incorrect path.

Running node.js packages on Windows outside the bin dir

I'm using the Node.js for Windows package (currently 0.4.2) downloaded from here:
http://www.rafaljonca.org/d/nodejs-windows
It works great - I can install packages with npm, and run packages like node-inspector, express, etc. The problem is that I can only run those packages if I'm in the bin directory of the distro. I run the setenv.cmd file, which adds bin to the path, but attempting to actually invoke a package (like install another package using npm) when I'm not in the bin path results in the following exception.
Error: Cannot find module '/npm '
at Function._resolveFilename (module.js:299:11)
at Function._load (module.js:245:25)
at Array.<anonymous> (module.js:402:10)
at EventEmitter._tickCallback (node.js:108:26)
I've tried setting the NODE_PATH environment variable to my node package dir, but that doesn't. help.
Though the question is 4 months old I've run into the same issue recently, so hopefully this is still useful.
There is a bug in the runnode.cmd file - there are 2 spaces at the end of line 4, after 'convArg=%%i'. If you remove them, the script will work.

Resources