Skip to content

Instantly share code, notes, and snippets.

@manuelbieh
Last active March 20, 2023 08:53
Show Gist options
  • Save manuelbieh/3864088 to your computer and use it in GitHub Desktop.
Save manuelbieh/3864088 to your computer and use it in GitHub Desktop.
Install node.js + some packages on Windows via Batchfile
@echo off
NET SESSION >nul 2>&1
IF %ERRORLEVEL% NEQ 0 (
echo This setup needs admin permissions. Please run this file as admin.
pause
exit
)
set NODE_VER=null
set NODE_EXEC=node-v0.8.11-x86.msi
set SETUP_DIR=%CD%
node -v >tmp.txt
set /p NODE_VER=<tmp.txt
del tmp.txt
IF %NODE_VER% NEQ null (
echo INSTALLING node ...
mkdir tmp
IF NOT EXIST tmp/%NODE_EXEC% (
echo Node setup file does not exist. Downloading ...
cd ../bin
START /WAIT wget http://nodejs.org/dist/v0.8.11/%NODE_EXEC%
move %NODE_EXEC% %SETUP_DIR%/tmp
)
cd %SETUP_DIR%/tmp
START /WAIT %NODE_EXEC%
cd %SETUP_DIR%
) ELSE (
echo Node is already installed. Proceeding ...
)
cd ../..
echo INSTALLING grunt ...
call npm install -g grunt-cli
REM echo INSTALLING grunt-less grunt-copy grunt-clean grunt-compress ...
REM call npm install grunt-contrib-less grunt-contrib-copy grunt-contrib-clean grunt-contrib-compress
cd %SETUP_DIR%
echo DONE!
@miparnisari
Copy link

This doesn't work for me. I get 'Windows cannot find wget'

@impressto
Copy link

You will need to install GnuWin for this script to work. See http://gnuwin32.sourceforge.net/packages/wget.htm

@arvind-india
Copy link

Not worked for me, Getting "Windows cannot find wget" error on execution

@Sv443
Copy link

Sv443 commented Apr 17, 2019

If you don't want to or can't use wget like me, use this:

set NULL_VAL=null
set NODE_VER=%NULL_VAL%
set NODE_EXEC=node-v10.15.3-x86.msi

node -v >.tmp_nodever
set /p NODE_VER=<.tmp_nodever
del .tmp_nodever

IF "%NODE_VER%"=="%NULL_VAL%" (
	echo.
	echo Node.js is not installed! Please press a key to download and install it from the website that will open.
	PAUSE
	start "" http://nodejs.org/dist/v10.15.3/%NODE_EXEC%
	echo.
	echo.
	echo After you have installed Node.js, press a key to shut down this process. Please restart it again afterwards.
	PAUSE
	EXIT
) ELSE (
	echo A version of Node.js ^(%NODE_VER%^) is installed. Proceeding...
)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment