Revisions for ⁨Install the latest portable version of Node.js without administrator rights.⁩

View the changes made to this paste.

public ⁨1⁩ ⁨file⁩ 2021-08-25 02:22:07 UTC

install.cmd

@@ -30,4 +30,5 @@ If "%npmnotexist%" == "true" (

 ) else (
 	echo npm is already installed!
 )
-echo Node.js and npm are installed!
\ No newline at end of file
+echo Node.js and npm are installed!
+// https://github.com/AlexAnimateMP4/nodejs-install-script
\ No newline at end of file

install.cmd

@@ -30,6 +30,4 @@ If "%npmnotexist%" == "true" (

 ) else (
 	echo npm is already installed!
 )
-set PATH=%PATH%;%CD%\nodejs;%CD%\npm
-echo Node.js and npm are installed!
-pause
\ No newline at end of file
+echo Node.js and npm are installed!
\ No newline at end of file

install.cmd

@@ -0,0 +1,35 @@

+@echo off
+chcp 65001 > NUL
+color 02
+If NOT exist "%CD%\node.exe" (
+	echo Installing Node.js...
+	curl -o "%CD%\node.exe" https://nodejs.org/dist/latest/win-x64/node.exe
+	echo Node.js is installed!
+) else (
+	echo Node.js is already installed!
+)
+set "psCmd="add-type -As System.Web.Extensions;$JSON = new-object Web.Script.Serialization.JavaScriptSerializer;$JSON.DeserializeObject((Invoke-WebRequest https://registry.npmjs.org/npm/latest).content).dist.tarball""
+for /f %%I in ('powershell -noprofile %psCmd%') do set "npmdownloadurl=%%I"
+set npmnotexist=false
+If NOT exist "%CD%\node_modules" set npmnotexist=true
+If NOT exist "%CD%\node_modules\npm" set npmnotexist=true
+If NOT exist "%CD%\npm.cmd" set npmnotexist=true
+If NOT exist "%CD%\npm" set npmnotexist=true
+If "%npmnotexist%" == "true" (
+	echo Installing npm...
+	If NOT exist "%CD%\node_modules" mkdir "%CD%\node_modules"
+	If NOT exist "%CD%\node_modules\npm" (
+		curl -o "%CD%\npm.tgz" "%npmdownloadurl%"
+		tar -xzf "%CD%\npm.tgz" -C "%CD%\node_modules"
+		ren "%CD%\node_modules\package" "npm"
+	)
+	If NOT exist "%CD%\npm.cmd" copy "%CD%\node_modules\npm\bin\npm.cmd" "%CD%"
+	If NOT exist "%CD%\npm" copy "%CD%\node_modules\npm\bin\npm" "%CD%"
+	If exist "%CD%\npm.tgz" del /f "%CD%\npm.tgz"
+	echo npm is installed!
+) else (
+	echo npm is already installed!
+)
+set PATH=%PATH%;%CD%\nodejs;%CD%\npm
+echo Node.js and npm are installed!
+pause
\ No newline at end of file