felixrieseberg / npm-windows-upgrade Goto Github PK
View Code? Open in Web Editor NEW:rocket: Upgrade npm on Windows
License: MIT License
:rocket: Upgrade npm on Windows
License: MIT License
I did a clean install of Node 12.7. I installed this and updated to npm 3.1.2. I installed some global packages, which installed in Program Files\NPM.
The global packages used to be installed in %appdata%.
%localappadata% is a better alternative.
Is this an issue with this script or just NPM 3.1.2. I'm asking here because I didn't see anything in the changelog about it for npm.
Hi guys I execute the script(Set-ExecutionPolicy Unrestricted -Scope CurrentUser -Force) from folder where you tool is located(disk D/npm-windows-upgrade-master) in cmd(that I run as admin) and see next message:
'Set-ExecutionPolicy' is not recognized as an internal or external command,
operable program or batch file.
Windows 7 64 bit
Hey,
First of all thanks a lot for this great tool! I've managed to update my npm to newest version without any problem. Although after this process I can't install modules without running console as administrator. Currently I am using ConEmu with GitBash and after running for example npm install -g ember-cli
I get an error:
npm ERR! Windows_NT 6.1.7601
npm ERR! argv "c:\\Program Files\\nodejs\\node.exe" "c:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install" "-g" "ember-cli"
npm ERR! node v4.0.0
npm ERR! npm v3.3.2
npm ERR! path c:\Program Files\nodejs\node_modules\.staging
npm ERR! code EPERM
npm ERR! errno -4048
npm ERR! syscall mkdir
npm ERR! Error: EPERM: operation not permitted, mkdir 'c:\Program Files\nodejs\node_modules\.staging'
npm ERR! at Error (native)
npm ERR! { [Error: EPERM: operation not permitted, mkdir 'c:\Program Files\nodejs\node_modules\.staging']
npm ERR! errno: -4048,
npm ERR! code: 'EPERM',
npm ERR! syscall: 'mkdir',
npm ERR! path: 'c:\\Program Files\\nodejs\\node_modules\\.staging' }
npm ERR!
npm ERR! Please try running this command again as root/Administrator.
npm ERR! Please include the following file with any support request:
npm ERR! C:\Users\marw\Workspace\npm-debug.log
/c/Program Files/nodejs/npm: line 27: 6072 Signal 112 (core dumped) "$NODE_EXE" "$NPM_CLI_JS" "$@"
I followed the installation instructions on the README.
Then, when I try to run the tool, I get an error:
λ npm-windows-upgrade
npm-windows-upgrade 0.3.2
? This tool will upgrade npm. Do you want to continue? Yes
R:\java\tools\npm\node_modules\npm-windows-upgrade\bin\npm-windows-upgrade:294
return console.err(chalk.bold.red('We have trouble connecting
^
TypeError: undefined is not a function
at R:\java\tools\npm\node_modules\npm-windows-upgrade\bin\npm-windows-upgrade:294:32
at R:\java\tools\npm\node_modules\npm-windows-upgrade\bin\npm-windows-upgrade:55:13
at GetAddrInfoReqWrap.asyncCallback [as callback] (dns.js:81:16)
at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:94:17)
There seems to be two problems.
I'm using node v0.12.7 and npm 2.11.3. behing a proxy
First, my working directory was C:\Program Files\nodejs\node_modules\npm
because I was troubleshooting and I was getting errors like EBUSY: resource busy or locked, rmdir 'C:\Program Files\nodejs\node_modules\npm'
. I finally realized what was going on and moved up a couple directoryies to nodejs so it was able to rmdir npm and node_modules, but then I got:
Cannot find module 'C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js'
which makes perfect sense given that it was just removed.
Now my system npm folder is gone and I'm in worse shape than I started so I'm going to try to reinstall from .MSI
Here's the full log of what happened:
C:\Program Files\nodejs\node_modules\npm>npm install -g npm-windows-upgrade
C:\Users\myusername\AppData\Roaming\npm\npm-windows-upgrade -> C:\Users\myusername\AppData\Roaming\npm\node_modules\npm-windows-upgrade\bin\npm-windows-upgrade
[email protected] C:\Users\myusername\AppData\Roaming\npm\node_modules\npm-windows-upgrade
├── [email protected]
├── [email protected] ([email protected], [email protected], [email protected], [email protected], [email protected])
├── [email protected] ([email protected], [email protected], [email protected], [email protected], [email protected])
└── [email protected] ([email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected])
C:\Program Files\nodejs\node_modules\npm>npm-windows-upgrade
npm-windows-upgrade 0.4.1
? This tool will upgrade npm. Do you want to continue? (Y/n) Y
? This tool will upgrade npm. Do you want to continue? Yes
? Which version do you want to install? 3.3.3
Upgrading.. |Error: npm
Error:
Error: ERR!
Error: Windows_NT 10.0.10240
Error: npm
Error: ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\myusername\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js" "install" "[email protected]"
Error: npm
Error: ERR! node v4.0.0
Error: npm ERR! npm v2.14.3
Error: npm ERR!
Error: path C:\Program Files\nodejs\node_modules\npm
npm ERR!
Upgrading.. /Error: code EBUSY
npm ERR! errno -4082
npm ERR! syscall rmdir
Error: npm ERR! EBUSY: resource busy or locked, rmdir 'C:\Program Files\nodejs\node_modules\npm'
npm ERR!
Error:
npm ERR! If you need help, you may report this error at:
npm ERR! <https://github.com/npm/npm/issues>
Upgrading.. \Error: npm
Error: ERR! error rolling back Error: EBUSY: resource busy or locked, rmdir 'C:\Program Files\nodejs\node_modules\npm'
npm ERR! error rolling back
Error: at Error (native)
npm ERR! error rolling back { [Error: EBUSY: resource busy or locked, rmdir 'C:\Program Files\nodejs\node_modules\npm']
npm ERR! error rolling back errno: -4082,
npm ERR! error rolling back code: 'EBUSY',
npm ERR!
Error: error rolling back syscall: 'rmdir',
npm ERR! error rolling back path: 'C:\\Program Files\\nodejs\\node_modules\\npm' }
Error:
Error: npm ERR! Please include the following file with any support request:
npm
Error: ERR! C:\Program Files\nodejs\npm-debug.log
Upgrading.. |
You wanted to install npm 3.3.3, but the installed version is2.14.3.
Please consider reporting your trouble to http://aka.ms/npm-issues.
Here is the output from the upgrader script:
[ '\r\n',
'\r\n',
' Directory: C:\\TEMP\r\n',
'\r\n',
'\r\n',
'Mode LastWriteTime Length Name \r\n',
'---- ------------- ------ ---- \r\n',
'd----- 2015-09-17 12:15 npm_upgrade \r\n',
'All done!\r\n',
'\r\n',
'\r\n' ] [ 'npm',
' ',
'ERR!',
' Windows_NT 10.0.10240\n',
'npm',
' ERR! argv "C:\\\\Program Files\\\\nodejs\\\\node.exe" "C:\\\\Users\\\\myusername\\\\AppData\\\\Roaming\\\\npm\\\\node_modules\\\\npm\\\\bin\\\\npm-cli.js" "install" "[email protected]"\n',
'npm',
' ERR! node v4.0.0\n',
'npm ERR! npm v2.14.3\n',
'npm ERR! ',
'path C:\\Program Files\\nodejs\\node_modules\\npm\nnpm ERR!',
' code EBUSY\nnpm ERR! errno -4082\nnpm ERR! syscall rmdir\n\n',
'npm ERR! EBUSY: resource busy or locked, rmdir \'C:\\Program Files\\nodejs\\node_modules\\npm\'\nnpm ERR!',
' \nnpm ERR! If you need help, you may report this error at:\nnpm ERR! <https://github.com/npm/npm/issues>\n',
'npm',
' ERR! error rolling back Error: EBUSY: resource busy or locked, rmdir \'C:\\Program Files\\nodejs\\node_modules\\npm\'\nnpm ERR! error rolling back',
' at Error (native)\nnpm ERR! error rolling back { [Error: EBUSY: resource busy or locked, rmdir \'C:\\Program Files\\nodejs\\node_modules\\npm\']\nnpm ERR! error rolling back errno: -4082,\nnpm ERR! error rolling back code: \'EBUSY\',\nnpm ERR!',
' error rolling back syscall: \'rmdir\',\nnpm ERR! error rolling back path: \'C:\\\\Program Files\\\\nodejs\\\\node_modules\\\\npm\' }\n',
'\n',
'npm ERR! Please include the following file with any support request:\nnpm ',
'ERR! C:\\Program Files\\nodejs\\npm-debug.log\n' ]
C:\Program Files\nodejs\node_modules\npm>node -v
v4.0.0
C:\Program Files\nodejs\node_modules\npm>npm-windows-upgrade
npm-windows-upgrade 0.4.1
? This tool will upgrade npm. Do you want to continue? (Y/n)
? This tool will upgrade npm. Do you want to continue? Yes
? Which version do you want to install? 3.3.3
Upgrading.. -Error: npm
Error:
Error: ERR!
Error: Windows_NT 10.0.10240
Error: npm
Error: ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\myusername\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js" "install" "[email protected]"
Error: npm
Error: ERR! node v4.0.0
npm ERR! npm v2.14.3
npm ERR! path C:\Program Files\nodejs\node_modules\npm
Error: npm ERR! code EBUSY
npm ERR! errno -4082
npm ERR! syscall rmdir
Error: npm ERR! EBUSY: resource busy or locked, rmdir 'C:\Program Files\nodejs\node_modules\npm'
npm ERR!
npm ERR! If you need help, you may report this error at:
npm ERR! <https://github.com/npm/npm/issues>
Upgrading.. |Error: npm
Error: ERR! error rolling back Error: EBUSY: resource busy or locked, rmdir 'C:\Program Files\nodejs\node_modules\npm'
npm ERR! error rolling back at Error (native)
npm ERR! error rolling back { [Error: EBUSY: resource busy or locked, rmdir 'C:\Program Files\nodejs\node_modules\npm']
npm
Error: ERR! error rolling back errno: -4082,
npm ERR! error rolling back code: 'EBUSY',
npm ERR! error rolling back syscall: 'rmdir',
npm ERR! error rolling back path: 'C:\\Program Files\\nodejs\\node_modules\\npm' }
Error:
Error: npm ERR! Please include the following file with any support request:
npm ERR! C:\Program Files\nodejs\npm-debug.log
Upgrading.. /
You wanted to install npm 3.3.3, but the installed version is2.14.3.
Please consider reporting your trouble to http://aka.ms/npm-issues.
Here is the output from the upgrader script:
[ 'All done!\r\n' ] [ 'npm',
' ',
'ERR!',
' Windows_NT 10.0.10240\n',
'npm',
' ERR! argv "C:\\\\Program Files\\\\nodejs\\\\node.exe" "C:\\\\Users\\\\myusername\\\\AppData\\\\Roaming\\\\npm\\\\node_modules\\\\npm\\\\bin\\\\npm-cli.js" "install" "[email protected]"\n',
'npm',
' ERR! node v4.0.0\nnpm ERR! npm v2.14.3\nnpm ERR! path C:\\Program Files\\nodejs\\node_modules\\npm\n',
'npm ERR! code EBUSY\nnpm ERR! errno -4082\nnpm ERR! syscall rmdir\n\n',
'npm ERR! EBUSY: resource busy or locked, rmdir \'C:\\Program Files\\nodejs\\node_modules\\npm\'\nnpm ERR! \nnpm ERR! If you need help, you may report this error at:\nnpm ERR! <https://github.com/npm/npm/issues>\n',
'npm',
' ERR! error rolling back Error: EBUSY: resource busy or locked, rmdir \'C:\\Program Files\\nodejs\\node_modules\\npm\'\nnpm ERR! error rolling back at Error (native)\nnpm ERR! error rolling back { [Error: EBUSY: resource busy or locked, rmdir \'C:\\Program Files\\nodejs\\node_modules\\npm\']\nnpm',
' ERR! error rolling back errno: -4082,\nnpm ERR! error rolling back code: \'EBUSY\',\nnpm ERR! error rolling back syscall: \'rmdir\',\nnpm ERR! error rolling back path: \'C:\\\\Program Files\\\\nodejs\\\\node_modules\\\\npm\' }\n',
'\n',
'npm ERR! Please include the following file with any support request:\nnpm ERR! C:\\Program Files\\nodejs\\npm-debug.log\n' ]
C:\Program Files\nodejs\node_modules\npm>cd ..
C:\Program Files\nodejs\node_modules>npm-windows-upgrade
npm-windows-upgrade 0.4.1
? This tool will upgrade npm. Do you want to continue? (Y/n) y
? This tool will upgrade npm. Do you want to continue? Yes
We could not show latest available versions. Try running this script again with the version you want to install (npm-windows-upgrade --version:3.0.0
C:\Program Files\nodejs\node_modules>npm-windows-upgrade --version:2.14.3
npm-windows-upgrade 0.4.1
? This tool will upgrade npm. Do you want to continue? (Y/n) Y
? This tool will upgrade npm. Do you want to continue? Yes
Upgrading.. \Error: module.js:338
throw err;
^
Error: Cannot find module 'C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js'
at Function.Module._resolveFilename (module.js:336:15)
at Function.Module._load (module.js:286:25)
at Function.Module.runMain (module.js:475:10)
at startup (node.js:117:18)
at node.js:951:3
Upgrading.. /Error: module.js:338
throw err;
^
Error: Cannot find module 'C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js'
at Function.Module._resolveFilename (module.js:336:15)
at Function.Module._load (module.js:286:25)
at Function.Module.runMain (module.js:475:10)
at startup (node.js:117:18)
at node.js:951:3
Upgrading.. -
Could not determine npm version.
You wanted to install npm 2.14.3, but the installed version isnull.
Please consider reporting your trouble to http://aka.ms/npm-issues.
Here is the output from the upgrader script:
[ 'All done!\r\n' ] [ 'module.js:338\r\n throw err;\r\n ^\r\n\r\nError: Cannot find module \'C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js\'\r\n at Function.Module._resolveFilename (module.js:336:15)\r\n at Function.Module._load (module.js:286:25)\r\n at Function.Module.runMain (module.js:475:10)\r\n at startup (node.js:117:18)\r\n at node.js:951:3\r\n',
'module.js:338\r\n throw err;\r\n ^\r\n\r\nError: Cannot find module \'C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js\'\r\n at Function.Module._resolveFilename (module.js:336:15)\r\n at Function.Module._load (module.js:286:25)\r\n at Function.Module.runMain (module.js:475:10)\r\n at startup (node.js:117:18)\r\n at node.js:951:3\r\n' ]
C:\Program Files\nodejs\node_modules>npm-windows-upgrade --version:2.14.3
npm-windows-upgrade 0.4.1
? This tool will upgrade npm. Do you want to continue? (Y/n) y
? This tool will upgrade npm. Do you want to continue? Yes
Upgrading.. -Error: npm
Error: ERR! Windows_NT 10.0.10240
Error: npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\myusername\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js" "install" "[email protected]"
npm ERR!
Error: node v4.0.0
npm ERR! npm v2.14.3
npm ERR! path C:\Program Files\nodejs\node_modules
npm ERR! code EBUSY
npm ERR! errno -4082
npm ERR! syscall rmdir
npm ERR! EBUSY: resource busy or locked, rmdir 'C:\Program Files\nodejs\node_modules'
npm
Error: ERR!
npm ERR! If you need help, you may report this error at:
npm ERR! <https://github.com/npm/npm/issues>
Error:
Error: npm ERR! Please include the following file with any support request:
npm ERR! C:\Program Files\nodejs\npm-debug.log
Upgrading.. \
Could not determine npm version.
You wanted to install npm 2.14.3, but the installed version isnull.
Please consider reporting your trouble to http://aka.ms/npm-issues.
Here is the output from the upgrader script:
[ 'All done!\r\n' ] [ 'npm',
' ERR! Windows_NT 10.0.10240\n',
'npm ERR! argv "C:\\\\Program Files\\\\nodejs\\\\node.exe" "C:\\\\Users\\\\myusername\\\\AppData\\\\Roaming\\\\npm\\\\node_modules\\\\npm\\\\bin\\\\npm-cli.js" "install" "[email protected]"\nnpm ERR!',
' node v4.0.0\nnpm ERR! npm v2.14.3\nnpm ERR! path C:\\Program Files\\nodejs\\node_modules\nnpm ERR! code EBUSY\nnpm ERR! errno -4082\nnpm ERR! syscall rmdir\n\nnpm ERR! EBUSY: resource busy or locked, rmdir \'C:\\Program Files\\nodejs\\node_modules\'\nnpm ',
'ERR! \nnpm ERR! If you need help, you may report this error at:\nnpm ERR! <https://github.com/npm/npm/issues>\n',
'\n',
'npm ERR! Please include the following file with any support request:\nnpm ERR! C:\\Program Files\\nodejs\\npm-debug.log\n' ]
C:\Program Files\nodejs\node_modules>cd ..
C:\Program Files\nodejs>npm-windows-upgrade --version:2.14.3
npm-windows-upgrade 0.4.1
? This tool will upgrade npm. Do you want to continue? (Y/n)
? This tool will upgrade npm. Do you want to continue? Yes
Upgrading.. \Error: module.js:338
throw err;
^
Error: Cannot find module 'C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js'
at Function.Module._resolveFilename (module.js:336:15)
at Function.Module._load (module.js:286:25)
at Function.Module.runMain (module.js:475:10)
at startup (node.js:117:18)
at node.js:951:3
Upgrading.. -Error: module.js:338
throw err;
^
Error: Cannot find module 'C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js'
at Function.Module._resolveFilename (module.js:336:15)
at Function.Module._load (module.js:286:25)
at Function.Module.runMain (module.js:475:10)
at startup (node.js:117:18)
at node.js:951:3
Upgrading.. \
Could not determine npm version.
You wanted to install npm 2.14.3, but the installed version isnull.
Please consider reporting your trouble to http://aka.ms/npm-issues.
Here is the output from the upgrader script:
[ 'All done!\r\n' ] [ 'module.js:338\r\n throw err;\r\n ^\r\n\r\nError: Cannot find module \'C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js\'\r\n at Function.Module._resolveFilename (module.js:336:15)\r\n at Function.Module._load (module.js:286:25)\r\n at Function.Module.runMain (module.js:475:10)\r\n at startup (node.js:117:18)\r\n at node.js:951:3\r\n',
'module.js:338\r\n throw err;\r\n ^\r\n\r\nError: Cannot find module \'C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js\'\r\n at Function.Module._resolveFilename (module.js:336:15)\r\n at Function.Module._load (module.js:286:25)\r\n at Function.Module.runMain (module.js:475:10)\r\n at startup (node.js:117:18)\r\n at node.js:951:3\r\n' ]
C:\Program Files\nodejs>
PS C:\WINDOWS\system32> npm-windows-upgrade
npm-windows-upgrade 0.4.0
? This tool will upgrade npm. Do you want to continue? Yes
? Which version do you want to install? 3.3.0
Upgrading.. |Error: npm
Error:
Error: http GET https://registry.npmjs.org/npm/3.3.0
Upgrading.. |Error: npm
Error:
Error: http
Error: 200 https://registry.npmjs.org/npm/3.3.0
Upgrading.. /Error: npm
Error:
Error: http
Error: GET https://registry.npmjs.org/npm/-/npm-3.3.0.tgz
Upgrading.. -Error: npm
Error:
Error: http
Error: 200 https://registry.npmjs.org/npm/-/npm-3.3.0.tgz
Upgrading.. -
Could not determine npm version.
You wanted to install npm 3.3.0, but the installed version isnull.
Please consider reporting your trouble to http://aka.ms/npm-issues.
Here is the output from the upgrader script:
[ '\r\n',
'\r\n',
' Directorio: C:\Users\svidal\AppData\Local\Temp\r\n',
'\r\n\r\n',
'Mode LastWriteTime Length Name
\r\n',
'---- ------------- ------ ----
\r\n',
'd---- 20/08/2015 10:11 npm_upgrade
\r\n',
'[email protected] node_modules\npm\n',
'All done!\r\n',
'\r\n',
'\r\n' ] [ 'npm',
' ',
'http GET https://registry.npmjs.org/npm/3.3.0\n',
'npm',
' ',
'http ',
'200 https://registry.npmjs.org/npm/3.3.0\n',
'npm',
' ',
'http',
' GET https://registry.npmjs.org/npm/-/npm-3.3.0.tgz\n',
'npm',
' ',
'http',
' 200 https://registry.npmjs.org/npm/-/npm-3.3.0.tgz\n' ]
PS C:\WINDOWS\system32> npm -v
module.js:340
throw err;
^
Error: Cannot find module 'are-we-there-yet'
at Function.Module._resolveFilename (module.js:338:15)
at Function.Module._load (module.js:280:25)
at Module.require (module.js:364:17)
at require (module.js:380:17)
at Object. (C:\Program Files (x86)\nodejs\node_modules\npm\node_modules\npmlog\log.js:2:16)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Module.require (module.js:364:17)
PS C:\WINDOWS\system32> npm-windows-upgrade
npm-windows-upgrade 0.4.0
? This tool will upgrade npm. Do you want to continue? Yes
We could not show latest available versions. Try running this script again with the version you want to install (npm-win
dows-upgrade --version:3.0.0
PS C:\WINDOWS\system32> npm-windows-upgrade --version:3.1.0
npm-windows-upgrade 0.4.0
? This tool will upgrade npm. Do you want to continue? Yes
Upgrading.. |Error:
module.js:340
throw err;
^
Error: Cannot find module 'are-we-there-yet'
at Function.Module._resolveFilename (module.js:338:15)
at Function.Module._load (module.js:280:25)
at Module.require (module.js:364:17)
at require (module.js:380:17)
at Object. (C:\Program Files (x86)\nodejs\node_modules\npm\node_modules\npmlog\log.js:2:16)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Module.require (module.js:364:17)
Upgrading.. /
Could not determine npm version.
You wanted to install npm 3.1.0, but the installed version isnull.
Please consider reporting your trouble to http://aka.ms/npm-issues.
Here is the output from the upgrader script:
[ 'All done!\r\n' ] [ '\r\nmodule.js:340\r\n throw err;\r\n ^\r\nError: Cannot find module 'are-we-there-ye
t'\r\n at Function.Module._resolveFilename (module.js:338:15)\r\n at Function.Module._load (module.js:280:25)\r\n
at Module.require (module.js:364:17)\r\n at require (module.js:380:17)\r\n at Object. (C:\Program
Files (x86)\nodejs\node_modules\npm\node_modules\npmlog\log.js:2:16)\r\n at Module._compile (module.js:456:26)
r\n at Object.Module._extensions..js (module.js:474:10)\r\n at Module.load (module.js:356:32)\r\n at Function.M
odule._load (module.js:312:12)\r\n at Module.require (module.js:364:17)\r\n' ]
@felixrieseberg I just updated to version 0.2.3 of npm-windows-upgrade because I was having the same issue described in issue #10
I then ran it (on Windows 8.1 pro) and got this error message:
PS C:\windows\system32> npm-windows-upgrade
npm-windows-upgrade 0.2.3
? This tool will upgrade npm. Do you want to continue? Yes
? Which version do you want to install? 2.12.1
Upgrading.. \
You wanted to install npm 2.12.1, but the installed version is2.11.2.
Please consider reporting your trouble to http://aka.ms/npm-issues.
Here is the output from the upgrader script:
[ '\r\n',
'\r\n',
' Directory: C:\\Users\\Warren\\AppData\\Local\\Temp\r\n',
'\r\n',
'\r\n',
'Mode LastWriteTime Length Name
\r\n',
'---- ------------- ------ ----
\r\n',
'd---- 7/7/2015 1:58 PM npm_upgrade
\r\n',
'[email protected] node_modules\\npm\n',
'All done!\r\n',
'\r\n',
'\r\n' ] []
But despite the error message, it looks like the upgrade happened:
PS C:\windows\system32> npm list -g --depth=0
C:\Users\Warren\AppData\Roaming\npm
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
└── [email protected]
I am new to node and npm so could be just something weird I did to my environment while learning and experimenting but thought I would report it.
npm-windows-upgrade
npm-upgrade-windows 0.1.5
? This tool will upgrade npm. Do you want to continue? Yes
? Which version do you want to install? 2.12.1
Upgrading.. -
npm-windows-upgrade\bin\npm-windows-upgrade:65
} else if (output[output.length].indexOf('All done!') > -1) {
^
TypeError: Cannot read property 'indexOf' of undefined
at C:\Users\User\AppData\Roaming\npm\node_modules\npm-windows-upgrade\bin\npm-windows-upgrade:65:41
at ChildProcess.<anonymous> (C:\Users\User\AppData\Roaming\npm\node_modules\npm-windows-upgrade\bin\npm-windows-upgrade:29:9)
at ChildProcess.emit (events.js:110:17)
at Process.ChildProcess._handle.onexit (child_process.js:1074:12)
I get this error after the elevated power-shell window is spawned. The upgrade finished successfully though and I confirmed it with npm version
Getting this error when trying to run
npm-windows-upgrade 0.2.6
? This tool will upgrade npm. Do you want to continue? Yes
undefined:1
♀
^
SyntaxError: Unexpected token ♀
at Object.parse (native)
at C:\...\AppData\Roaming\npm\node_modules\npm-windows-upgrade\bin\npm-windows-upgrade:72:17
at ChildProcess.exithandler (child_process.js:187:7)
at emitTwo (events.js:87:13)
at ChildProcess.emit (events.js:172:7)
at maybeClose (internal/child_process.js:764:16)
at Socket.<anonymous> (internal/child_process.js:319:11)
at emitOne (events.js:77:13)
at Socket.emit (events.js:169:7)
at Pipe._onclose (net.js:467:12)
Windows 8.1 PowerShell version 4
I run Windows 10 (build 10163). The command "Set-ExecutionPolicy Unrestricted -Scope CurrentUser" did not work for the "npm-windows-upgrade" command.
Windows PowerShell
Copyright (C) 2015 Microsoft Corporation. All rights reserved.
PS C:\WINDOWS\system32> Set-ExecutionPolicy Unrestricted -Scope CurrentUser
PS C:\WINDOWS\system32> npm-windows-upgrade
npm-windows-upgrade 0.2.6
? This tool will upgrade npm. Do you want to continue? Yes
Scripts cannot be executed on this system. <<<<<< ERROR
To fix this issue, please run the command below as Administrator and try again:
Adding the "-Force" parameter fix the problem.
The result is below.
PS C:\Program Files (x86)\nodejs> Set-ExecutionPolicy Unrestricted -Scope CurrentUser -Force
PS C:\Program Files (x86)\nodejs> npm-windows-upgrade
npm-windows-upgrade 0.2.6
? This tool will upgrade npm. Do you want to continue? Yes
? Which version do you want to install? 3.1.3
Upgrading.. -
Upgrade finished. Your new npm version is 3.1.3. Have a nice day!
PS C:\Program Files (x86)\nodejs>
You wanted to install npm 3.2.0, but the installed version is1.4.9.
Please consider reporting your trouble to http://aka.ms/npm-issues.
Here is the output from the upgrader script:
[ '\r\n',
'\r\n',
' Directory: C:\\Users\\<username>\\AppData\\Local\\Temp\r\n',
'\r\n',
'\r\n',
'Mode LastWriteTime Length Name
\r\n',
'---- ------------- ------ ----
\r\n',
'd---- 27-Jul-15 5:47 PM npm_upgrade
\r\n',
'[email protected] node_modules\\npm\n',
'All done!\r\n',
'\r\n',
'\r\n' ] []
We should keep the dependencies small and use only a promise and async/await polyfill.
This line should have an expression - ${env:ProgramFiles(x86)}
Upgrading.. -Error: At C:\Users\jonno\AppData\Roaming\npm\node_modules\npm-windows-upgrade\powershell\upgrade-npm.ps1:5
8 char:33
Error: + $npmPath = $env:ProgramFiles(x86) + "\nodejs\node_modules\npm"
+ ~
Unexpected token '(' in expression or statement.
+ CategoryInfo : ParserError: (:) [], ParseException
+ FullyQualifiedErrorId : UnexpectedToken
I am receiving the following error when executing npm-windows-upgrade
(sorry for the horrible formatting, just dumping a copy/paste from my cmd window):
You wanted to install npm 3.1.3, but the installed version is2.11.3.
Please consider reporting your trouble to http://aka.ms/npm-issues.
Here is the output from the upgrader script:
[ 'C:\\Users\\Dave\\AppData\\Roaming\\npm\\npm -> C:\\Users\\Dave\\AppData\\Roam
ing\\npm\\node_modules\\npm\\bin\\npm-cli.js\n',
'C:\\Users\\Dave\\AppData\\Roaming\\npm\n└── [email protected] \n\n',
'All done!\r\n' ] [ 'npm',
' WARN EPACKAGEJSON C:\\Users\\Dave\\AppData\\Roaming\\npm No description\n',
'npm ',
'WARN EPACKAGEJSON C:\\Users\\Dave\\AppData\\Roaming\\npm No repository field.
\n',
'npm WARN EPACKAGEJSON C:\\Users\\Dave\\AppData\\Roaming\\npm No README data\n
',
'npm WARN EPACKAGEJSON C:\\Users\\Dave\\AppData\\Roaming\\npm No license field
.\n' ]
Executing npm -v
returns 2.11.3
at this point.
I ended up executing npm install -g [email protected]
and copying the contents of the roaming npm folder to %programfiles%\nodejs\node_modules\npm and ran npm-windows-upgrade
again for kicks and giggles, and it reported the same warnings, but then counted the upgrade as a success.
Here's my specs:
Node: v0.12.7
Npm: v2.11.3
Windows: 8 x64 Professional
(no IO.js is currently installed, but it was at one point)
I'm getting this error in upgrade-npm.ps1
Cannot bind argument to parameter 'Path' because it is null.
+ CategoryInfo : InvalidData: (:) [upgrade-npm.ps1], ParameterBindingValidationException
+ FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,upgrade-npm.ps1
If you install VS 2015 first, then use this tool, it will break the Tools for Apache Cordova config so that VS can no longer build Apache Cordova packages. That's because it changes the -g prefix directory, so vs-tac and all the dependencies, which are installed under AppData by default, will appear to be missing.
Clean install of Node.js 5.4.1, attempting to upgrade npm yields the following:
C:\Windows\system32> npm-windows-upgrade
npm-windows-upgrade 1.2.0
? This tool will upgrade npm. Do you want to continue? Yes
? Which version do you want to install? 3.5.4
Upgrading... /Error: npm
Error:
Error: WARN ENOENT ENOENT: no such file or directory, open 'C:\Program Files\nodejs\package.json'
Error: npm
Error: WARN EPACKAGEJSON nodejs No description
Error: npm
Error: WARN EPACKAGEJSON nodejs No repository field.
Error: npm WARN
Error: EPACKAGEJSON nodejs No README data
Error: npm WARN
Error: EPACKAGEJSON nodejs No license field.
Error: npm
Error: WARN EBUNDLEOVERRIDE Replacing bundled node_modules\npm\node_modules\init-package-json with new installed versi
on
Error: npm
Error: WARN EBUNDLEOVERRIDE Replacing bundled node_modules\npm\node_modules\node-gyp with new installed version
Error: npm
Error: WARN EBUNDLEOVERRIDE Replacing bundled node_modules\npm\node_modules\npm-install-checks with new installed versi
on
Error: npm
Error: WARN EBUNDLEOVERRIDE Replacing bundled node_modules\npm\node_modules\npmlog with new installed version
Upgrading... -Error: npm WARN EBUNDLEOVERRIDE Replacing bundled node_modules\npm\node_modules\read-package-json with ne
w installed version
We encountered an error during installation.
Please consider reporting your trouble to http://aka.ms/npm-issues.
Here is the error:
Could not determine npm version.
After the install failed, it completely broke npm and required me to run the Node.js installer to repair the installation. That fixed npm and allowed the script to work the 2nd attempt. But this issue happened on a fresh install of the latest Node.js.
First things first: Great tool, thanks a lot!
Feature Proposal:
It would be nice to be able to override the update confirmation prompt with a parameter, e.g. --no-prompt
or --no-confirmation
, just like --version
.
Background:
I'm working on several native node modules on an automated build system (AppVeyor).
The modules are compiled with different node versions.
To get consistent npm
behaviour I would like to use the same npm version with all node versions I'm targeting.
As quick fix, I completely removed the prompt for my automated builds:
npm-windows-upgrade/bin/npm-windows-upgrade
Lines 268 to 272 in c266264
This whole thing should use more canonical options.
Platform Win7
C:\>npm-windows-upgrade
npm-windows-upgrade 0.4.5
? This tool will upgrade npm. Do you want to continue? Yes
? Which version do you want to install? 2.14.8
Upgrading... -
C:\>
Installing a new npm version with --npm-path:"C:\tools\nodejs"
cli-parameter set works.
Thanks for your work 👍
Would be nice to automatically select the latest version, so (together with #25) we can do a fully unattended upgrade. Something like
npm-windows-upgrade --quiet --version:latest
Or something. Currently doesn't work, as there's no version, or an alias for a version, called "latest".
I install npm-windows-upgrade,but when i use it to update my npm,have the problems:
npm-windows-upgrade 0.2.6
? This tool will upgrade npm. Do you want to continu
Scripts cannot be executed on this system.
To fix this issue, please run the command below as A
Set-ExecutionPolicy Unrestricted -Scope CurrentUser
Hi when i tried to upgrade to beta 3.1.0 version from 2.11.2, i am getting the following error. This is from windows 7.
C:\Windows\system32> npm-windows-upgrade
npm-windows-upgrade 0.2.0
? This tool will upgrade npm. Do you want to continue? Yes
? Which version do you want to install? 3.1.0
Upgrading.. -Error: Write-Debug : A positional parameter cannot be found that accepts argument '+'.
Error: At C:\Users\Ram\AppData\Roaming\npm\node_modules\npm-windows-upgrade\powershell\upgrade-npm.ps1:64 char:12
+ Write-Debug <<<< "Assuming npm in " + $NpmPath
+ CategoryInfo : InvalidArgument: (:) [Write-Debug], ParentContainsErrorRecordException
+ FullyQualifiedErrorId : PositionalParameterNotFound,Microsoft.PowerShell.Commands.WriteDebugCommand
Upgrading.. \
You wanted to install npm 3.1.0, but the installed version is2.11.2.
Please consider reporting your trouble to http://aka.ms/npm-issues.
Here is the output from the upgrader script:
[] [ 'Write-Debug : A positional parameter cannot be found that accepts argument \'+\'.\r\n',
'At C:\\Users\\Ram\\AppData\\Roaming\\npm\\node_modules\\npm-windows-upgrade\\powershell\\upgrade-npm.ps1:64 char:1
2\r\n+ Write-Debug <<<< "Assuming npm in " + $NpmPath\r\n + CategoryInfo : InvalidArgument: (:) [Write-Debu
g], ParentContainsErrorRecordException\r\n + FullyQualifiedErrorId : PositionalParameterNotFound,Microsoft.PowerShell
.Commands.WriteDebugCommand\r\n \r\n' ]�
Here is the error:
[ 'Could not find installation location (assumed in C:\\Program Files (x86)\\nodejs) - aborting upgrade\r\n' ] []
By default nodejs installed at C:\\nodejs
for me so I would assume there is some way to configure npm-windows-upgrade to look in another location? Is there, maybe, a script parameter to pass in representing the installed location of nodejs?
Thanks
It seems like npm will not always update successfully if Node was installed with Cocolatey. We should have a test for that.
I am following the instructions step by step. npm-windows-upgrade
installed successfully.
But when I run npm-windows-upgrade --npm-path:"C:\NodeJS" --version:3.3.9
, I got error.
Output from elevated powershell:
npm-windows-upgrade --npm-path:"C:\NodeJS" --version:3.3.9
npm-windows-upgrade 0.4.8
? This tool will upgrade npm. Do you want to continue? (Y/n) y
? This tool will upgrade npm. Do you want to continue? Yes
Upgrading... -Error: npm
Error: ERR! Windows_NT 10.0.10240
Error: npm
Error: ERR! argv "C:\\NodeJS\\node.exe" "C:\\NodeJS\\node_modules\\npm\\bin\\npm-cli.js" "install" "[email protected]"
Error: npm ERR! node
Error: v4.2.1
npm ERR!
Error: npm v2.14.7
npm
Error: ERR! path C:\NodeJS\node_modules\npm
npm
Error: ERR! code EPERM
Error: npm ERR! errno -4048
Error: npm ERR! syscall lstat
Error:
Error: npm
Error: ERR! Error: EPERM: operation not permitted, lstat 'C:\NodeJS\node_modules\npm'
npm ERR!
Error: at Error (native)
npm ERR! { [Error: EPERM: operation not permitted, lstat 'C:\NodeJS\node_modules\npm']
Error: npm ERR! errno: -4048,
npm ERR! code: 'EPERM',
Error: npm
Error: ERR! syscall: 'lstat',
npm ERR! path: 'C:\\NodeJS\\node_modules\\npm' }
Error: npm ERR!
npm ERR!
Error: Please try running this command again as root/Administrator.
Error: npm
Error: ERR! error rolling back Error: EPERM: operation not permitted, lstat 'C:\NodeJS\node_modules\npm'
npm
Error: ERR! error rolling back at Error (native)
npm ERR! error rolling back { [Error: EPERM: operation not permitted, lstat 'C:\NodeJS\node_modules\npm']
npm
Error: ERR! error rolling back errno: -4048,
npm ERR! error rolling back code: 'EPERM',
npm ERR! error rolling back syscall: 'lstat',
Error: npm
Error:
Error: ERR!
Error:
Error: error rolling back
Error: path: 'C:\\NodeJS\\node_modules\\npm' }
Error:
Error: npm ERR! Please include the following file with any support request:
npm ERR! C:\NodeJS\npm-debug.log
Upgrading... \
My npmrc
prefix = C:\NodeJS
cache = C:\NodeJS\npm-cache
init-module = C:\NodeJS\npm-init.js
globalconfig = C:\NodeJS\etc\npmrc
globalignorefile = C:\NodeJS\etc\npmignore
userconfig = C:\NodeJS\etc\npmrc
npm-debug.log > https://gist.github.com/zmni/9217b2e84bc91ccba0fc
npm-windows-upgrade
per se works great, but upgrade output on AppVeyor is a bit weird.
Any chance you might consider to look into this rather cosmetic-only request?
https://ci.appveyor.com/project/Mapbox/node-mapnik/build/1.0.839/job/r29p489lwrvbyg68#L25
/cc @FeodorFitsner
This installer replaces node correctly however it does not generate the npmrc file. Without this file, npm requires admin rights to install global packages into nodejs\node_modules.
The nodejs.org 4.x and new 5.0 (which has [email protected]) installs global packages into %appdata%\npm.
It does this with the npmrc
file which would be in nodejs/node_modules/npm/npmrc
.
npmrc contents
prefix=${APPDATA}\npm
Edit:
It looks like you are copying the npmrc file to temp and copying it back after install, but this is not working because the filename is incorrect. It's npmrc
not .npmrc
, not sure if this changed in 3.x but in 3.x it's npmrc
I have the default installation of Node.js for Windows (node-v0.12.7-x86.msi). After following the instructions on https://www.npmjs.com/package/npm-windows-upgrade and executing npm-windows-upgrade
in the PowerShell console I got the following error:
npm-windows-upgrade : The term 'npm-windows-upgrade' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or
if a path was included, verify that the path is correct and try again.
At line:1 char:1
+ npm-windows-upgrade
+ ~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (npm-windows-upgrade:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
I am following the instructions for upgrading NPM using npm-windows-upgrade.
The upgrade tool installs successfully, then I run npm-windows-upgrade.
PS C:\Users\Gregg> npm-windows-upgrade npm-windows-upgrade 0.4.6
? This tool will upgrade npm. Do you want to continue? Yes
events.js:85
throw er; // Unhandled 'error' event
^
Error: spawn powershell.exe ENOENT
at exports._errnoException (util.js:746:11)
at Process.ChildProcess._handle.onexit (child_process.js:1053:32)
at child_process.js:1144:20
at process._tickCallback (node.js:355:11)
I tried this with passing the path to the nodejs folder, and the result was the same.
This is being run on a Windows 7 Professional, Service Pack 1 64 bit box.
I ran this successfully on another machine which is a 2008R2 Server.
Greg
I was not able to install any packages with npm(some windows NT error), so I update node and tried to update npm
https://github.com/felixrieseberg/npm-windows-upgrade as this suggested.
I started power shell as administrator
Entered command as suggested
on
npm install -g npm-windows-upgrade
I selected 3.5.3
this shows me the error
Upgrading... /Error: npm
Upgrading... -Error:
Error: WARN
Error:
Error: enoent
Error: ENOENT: no such file or directory, open 'C:\Program Files\nodejs\package.json'
Error: npm
Error:
Error: WARN
Error: nodejs No description
Error: npm WARN nodejs No repository field.
npm WARN nodejs No README data
npm WARN nodejs No license field.
Upgrading... /
You wanted to install npm 3.5.3, but the installed version is3.5.2.
Please consider reporting your trouble to http://aka.ms/npm-issues.
Here is the error:
Hi,
When I launch the basic commande : npm-windows-updrade and say Yes I have this error :
undefined:1
♀
^
SyntaxError: Unexpected token ♀
at Object.parse (native)
at C:\Users\a.huc\AppData\Roaming\npm\node_modules\npm-windows-upgrade\bin\npm-windows-upgrade:79:17
at ChildProcess.exithandler (child_process.js:742:7)
at ChildProcess.emit (events.js:110:17)
at maybeClose (child_process.js:1015:16)
at Process.ChildProcess._handle.onexit (child_process.js:1087:5)
How can I correct it ?
So when I first tried this (on win 7) I got:
Error: (x86)\nodejs\node_modules\npm-windows-upgrade\powershell\upgrade-npm.ps1 cannot be loaded because running scripts is disabled on this system. For more information, see about_Execution_Policies at http://go.microsoft.com/fwlink/?LinkID=135170.
Now, it was easy enough to work around this with:
Set-ExecutionPolicy Unrestricted -Scope CurrentUser
But it seems like this should be documented or tested for or something?
Looks like a problem parsing the powershell output. The error occurred just after Upgrading npm in C:\Program Files\nodejs
appeared in the powershell window.
Upgrade did complete successfully.
Upgrading.. \
C:\Users\btp\AppData\Roaming\npm\node_modules\npm-windows-upgrade\bin\npm-windows-upgrade:65
} else if (output[output.length - 1].indexOf('All done!') > -1) {
^
TypeError: Cannot read property 'indexOf' of undefined
at C:\Users\btp\AppData\Roaming\npm\node_modules\npm-windows-upgrade\bin\npm-windows-upgrade:65:45
at ChildProcess.<anonymous> (C:\Users\btp\AppData\Roaming\npm\node_modules\npm-windows-upgrade\bin\npm-windows-upg
rade:29:9)
at ChildProcess.emit (events.js:110:17)
at Process.ChildProcess._handle.onexit (child_process.js:1074:12)
I am getting the following error while trying to run this command. Any help would be greatly appreciated. Thanks!
C:\Users\dcollier
λ Set-ExecutionPolicy Unrestricted -Scope CurrentUser -Force
C:\Users\dcollier
λ npm install -g npm-windows-upgrade npm-windows-upgrade
npm WARN install:mkdirp ENOENT: no such file or directory, chmod 'C:\Users\dcollier\AppData\Roaming\npm\node_modules\npm-windows-upgrade\node_modules\mkdirp\b'
npm WARN install:rimraf ENOENT: no such file or directory, chmod 'C:\Users\dcollier\AppData\Roaming\npm\node_modules\npm-windows-upgrade\node_modules\utile\node_modules\rimraf\b'
C:\Users\dcollier\AppData\Roaming\npm
└── (empty)
npm ERR! code 1
C:\Users\dcollier
λ
Anytime I try to upgrade, the script fails with the following screen:
http://i.imgur.com/bT3eLxp.png
The 'Here is the error:' block is always empty so I am not sure as to why this is failing. It has always worked in the past, but tonight it does not seem to want to cooperate.
might be related to #15 and #13
PS C:\WINDOWS\system32> Set-ExecutionPolicy Unrestricted -Scope CurrentUser -Force
PS C:\WINDOWS\system32> node -v
v0.12.7
PS C:\WINDOWS\system32> npm -v
2.11.3
PS C:\WINDOWS\system32> npm-windows-upgrade
npm-windows-upgrade 0.2.10
? This tool will upgrade npm. Do you want to continue? Yes
undefined:1
npm command view
^
SyntaxError: Unexpected token p
at Object.parse (native)
at C:\Users\falei\AppData\Roaming\npm\node_modules\npm-windows-upgrade\bin\npm-windows-upgrade:73:17
at ChildProcess.exithandler (child_process.js:742:7)
at ChildProcess.emit (events.js:110:17)
at maybeClose (child_process.js:1015:16)
at Socket.<anonymous> (child_process.js:1183:11)
at Socket.emit (events.js:107:17)
at Pipe.close (net.js:485:12)
PS C:\WINDOWS\system32>
PS C:\WINDOWS\system32> npm-windows-upgrade --version:3.1.0
npm-windows-upgrade 0.2.10
? This tool will upgrade npm. Do you want to continue? Yes
Upgrading.. -Error: Join-Path : Cannot find drive. A drive with the name 'npm command configC' does not exist.
Error: At C:\Users\falei\AppData\Roaming\npm\node_modules\npm-windows-upgrade\powershell\upgrade-npm.ps1:103 char:20
+ $AssumedNpmPath = (Join-Path $NodePath "node_modules\npm")
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (npm command configC:String) [Join-Path], DriveNotFoundException
+ FullyQualifiedErrorId : DriveNotFound,Microsoft.PowerShell.Commands.JoinPathCommand
You wanted to install npm 3.1.0, but the installed version is2.11.3.
Please consider reporting your trouble to http://aka.ms/npm-issues.
Here is the output from the upgrader script:
[] [ 'Join-Path : Cannot find drive. A drive with the name \'npm command configC\' does not exist.\r\n',
'At C:\\Users\\falei\\AppData\\Roaming\\npm\\node_modules\\npm-windows-upgrade\\powershell\\upgrade-npm.ps1:103 char:2
0\r\n+ $AssumedNpmPath = (Join-Path $NodePath "node_modules\\npm")\r\n+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~\r\n + CategoryInfo : ObjectNotFound: (npm command configC:String) [Join-Path], DriveNotFoundExcept
ion\r\n + FullyQualifiedErrorId : DriveNotFound,Microsoft.PowerShell.Commands.JoinPathCommand\r\n \r\n' ]
I used ${env:ProgramFiles(x86)} everywhere I could and it fixed it on Windows 10.
# npm-windows-upgrade
# This script updates npm on Windows, making sure that the npm installed
# with `npm install -g npm@latest` is actually the first npm found in PATH
# (C) Copyright 2015 Microsoft, developed by Felix Rieseberg
# [email protected]
# ----------------------------------------------------------------------
# Usage: ./upgrade-npm.ps1
# ----------------------------------------------------------------------
[CmdletBinding()]
Param(
[Parameter(Mandatory=$True)]
[string]$version,
[string]$NodePath=(Join-Path ${env:ProgramFiles(x86)} nodejs)
)
$ErrorActionPreference = "Stop"
#
# Self-Elevate
# ---------------------------------------------------------------------------------------------------------
function IsAdministrator
{
$Identity = [System.Security.Principal.WindowsIdentity]::GetCurrent()
$Principal = New-Object System.Security.Principal.WindowsPrincipal($Identity)
$Principal.IsInRole([System.Security.Principal.WindowsBuiltInRole]::Administrator)
}
function IsUacEnabled
{
(Get-ItemProperty HKLM:\Software\Microsoft\Windows\CurrentVersion\Policies\System).EnableLua -ne 0
}
function UpdateNpm($PassedNodePath)
{
$NpmPath = (Join-Path $PassedNodePath "node_modules\npm")
Write-Debug "Assuming npm in $NpmPath"
if (Test-Path $PassedNodePath)
{
# Create tmp directory, delete files if they exist
$TempPath = "$env:temp\npm_upgrade"
if ((Test-Path $TempPath) -ne $True)
{
New-Item -ItemType Directory -Force -Path $TempPath
}
# Copy away .npmrc
$Npmrc = $False
if (Test-Path $NpmPath)
{
cd $NpmPath
if (Test-Path .npmrc)
{
$Npmrc = $True
Write-Debug "Saving .npmrc"
Copy-Item .npmrc $TempPath
}
}
# Upgrade npm
cd $PassedNodePath
Write-Debug "Upgrading npm in $PassedNodePath"
.\npm install npm@$version
# Copy .npmrc back
if ($Npmrc)
{
Write-Debug "Restoring .npmrc"
$TempFile = "$TempPath\.npmrc"
Copy-Item $TempFile $NpmPath -Force
}
"All done!"
} else
{
"Could not find installation location (assumed in $PassedNodePath) - aborting upgrade"
}
}
if (!(IsAdministrator))
{
if (IsUacEnabled)
{
"We need to relaunch this script as administrator"
[string[]]$argList = @('-NoProfile', '-NoExit', '-File', $MyInvocation.MyCommand.Path)
$argList += $MyInvocation.BoundParameters.GetEnumerator() | Foreach {"-$($_.Key)", "$($_.Value)"}
$argList += $MyInvocation.UnboundArguments
Start-Process PowerShell.exe -Verb Runas -WorkingDirectory $pwd -ArgumentList $argList
return
}
else
{
"You must be administrator to run this script"
return
}
}
#
# Upgrade
# ---------------------------------------------------------------------------------------------------------
$AssumedNpmPath = (Join-Path $NodePath "node_modules\npm")
if ((Test-Path $AssumedNpmPath) -ne $True)
{
$NodePath = (Join-Path ${env:ProgramFiles(x86)} nodejs)
# If the user installed an x86 version of NodeJS on an x64 system, the NodeJS installation will be found
# in env:ProgramFiles(x86)
if ((Test-Path $NodePath) -ne $True) {
if (Test-Path "Env:ProgramFiles(x86)")
{
$NodePath = (Join-Path ${env:ProgramFiles(x86)} nodejs)
}
else
{
"We could not find npm - aborting upgrade"
return
}
}
}
UpdateNpm($NodePath)
node js installed on program files. and therefore npm is. older node did roaming. but after using this module it turned out the the roaming does not exist. and npm is tring to write to program files. which fails. any idea how to over come this issue? thanks!!
I'm running io.js 2.4.0. The error message is similar to #10 but happens in upgrade-npm.ps1
rather than Microsoft.PowerShell.Commands.WriteDebugCommand
if I'm reading it correctly:
PS C:\> npm-windows-upgrade
npm-windows-upgrade 0.2.6
? This tool will upgrade npm. Do you want to continue? (Y/n)
? This tool will upgrade npm. Do you want to continue? Yes
? Which version do you want to install? 3.1.3
Upgrading.. |Error: C:\Users\Rosalie\AppData\Roaming\npm\node_modules\npm-windows-upgrade\powershell\upgrade-npm.ps1 :
Impossible de
Error: trouver un param?tre positionnel acceptant l'argument ?env:ProgramFiles(x86)?.
Au caract?re Ligne:1 : 4
+ & {& 'C:\Users\Rosalie\AppData\Roaming\npm\node_modules\npm-windows-upgrade\powe ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument : (:) [upgrade-npm.ps1], ParameterBindingException
+ FullyQualifiedErrorId : PositionalParameterNotFound,upgrade-npm.ps1
You wanted to install npm 3.1.3, but the installed version is2.13.0.
Please consider reporting your trouble to http://aka.ms/npm-issues.
Here is the output from the upgrader script:
[] [ 'C:\\Users\\Rosalie\\AppData\\Roaming\\npm\\node_modules\\npm-windows-upgrade\\powershell\\upgrade-npm.ps1 : Imposs
ible de \r\n',
'trouver un param?tre positionnel acceptant l\'argument ?env:ProgramFiles(x86)?.\r\nAu caract?re Ligne:1 : 4\r\n+ & {&
\'C:\\Users\\Rosalie\\AppData\\Roaming\\npm\\node_modules\\npm-windows-upgrade\\powe ...\r\n+ ~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\r\n + CategoryInfo : InvalidArgument : (:) [upgrade-
npm.ps1], ParameterBindingException\r\n + FullyQualifiedErrorId : PositionalParameterNotFound,upgrade-npm.ps1\r\n \r\
n' ]
I'm running the script on a PC with Windows 8 32-bit (EDIT: previously erroneously stated it was Windows 7) so while I have the 32-bit version of io.js, I don't have a Program Files (x86)
folder... which the error log mentions so it could be related?
I can only find reference to the npm install in ProgramFiles, I didn't see a reference to $env:APPDATA
I haven't spent much time looking at how the script works, but can it upgrade npm installs in AppData\Roaming\npm too? I noticed the npm documentation references this tool but there's no mention to dealing with AppData installs
Hi, my system is windows 10. I followed the instructions, and this is what comes out:
C:\WINDOWS\system32> npm-windows-upgrade
npm-windows-upgrade 0.5.1
? This tool will upgrade npm. Do you want to continue? (Y/n) Y
? This tool will upgrade npm. Do you want to continue? Yes
? Which version do you want to install? 3.3.12
Upgrading... \Error: npm
Error: WARN ENOENT ENOENT: no such file or directory, open 'C:\Program Files\nodejs\package.json'
Error: npm
Error: WARN EPACKAGEJSON nodejs No description
Error: npm
Error: WARN EPACKAGEJSON nodejs No repository field.
Error: npm WARN EPACKAGEJSON nodejs No README data
Error: npm
Error: WARN EPACKAGEJSON nodejs No license field.
Upgrading... |
Any idea why it's asking for the package.json? There's no such file in the location it's looking for.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.