A “nodevars.bat” to get you running

This is the contenat of my nodevars.bat file that I use to run the node command line interface;

@echo off

rem Ensure this Node.js and npm are first in the PATH
set PATH=%APPDATA%\npm;%~dp0;%PATH%

setlocal enabledelayedexpansion
pushd "%~dp0"

rem Figure out the node version.
set print_version=.\node.exe -p -e "process.versions.node + ' (' + process.arch + ')'"
for /F "usebackq delims=" %%v in (`%print_version%`) do set version=%%v

rem Print message.
if exist npm.cmd (
echo Your environment has been set up for using Node.js !version! and npm.
) else (
echo Your environment has been set up for using Node.js !version!.
)

popd
endlocal

rem If we're in the node.js directory, change to the user's home dir.
if "%CD%\"=="%~dp0" cd /d "D:\apps"

# Change default code page of Windows console to UTF-8 : http://superuser.com/a/685264/28233
REM change CHCP to UTF-8
CHCP 65001

One thought on “A “nodevars.bat” to get you running

  1. Tom says:

    After changing the code page to 65001, the npm installation message got messed up. It changed from:

    [email protected].0 D:\dev\nodejs\node_modules\grunt-contrib-cssmin
    ├── [email protected] ([email protected], [email protected], [email protected])
    ├── [email protected] ([email protected])
    └── [email protected] ([email protected], [email protected], [email protected], [email protected])

    To:

    [email protected].0 D:\dev\nodejs\node_modules\grunt-contrib-cssmin
    ÃÄÄ [email protected] ([email protected], [email protected], [email protected])
    ÃÄÄ [email protected] ([email protected])
    ÀÄÄ [email protected] ([email protected], [email protected], [email protected], [email protected])

    I suggest keeping the default code page (437).

Comments are closed.