powershell - npm install sometimes fails in Visual Studio Online -
i had problems vs online , nuget-restore. report couldn't find packages, visual studio 2015 found , installed. specified in nuget's targets file use apiv3 , apiv2. since than, nuget packages found, i'm starting experience different, rather random, errors npm.
i've pre-build script (configured in project file) installs necessary npm , bower packages, , afterwards runs gulp. works fine locally, , of times online. every ~4th time on average, exception similar this:
eperm, open 'c:\npm\cache\fedb6d47-pm-cache-clone-1-0-2-package-tgz.lock'
or this:
eperm, open 'c:\npm\cache\ca5822dc-sh-isarguments-3-0-4-package-tgz.lock'
i working on gulpfile in beginning, thought of changes caused it, now, i'm not touching project anymore, , compiled fine until got error again.
in meanwhile, i've added tiny change commit , push it, , compiles fine again. idea can cause , how can @ least reduce risk of getting error?
here pre-build powershell script:
param($build_config) $webprojectname = "web_project" $scriptpath = $myinvocation.mycommand.path $dir = split-path $scriptpath cd $dir cd ..\src\$webprojectname echo "npm install" npm install echo "bower install" bower install echo "gulp $build_config" gulp $build_config update:
i used execute powershell script via
powershell -file script.ps1 and after switching to
powershell -noninteractive -noprofile -command script.ps1 it seemed have fixed error, after ~20 successful builds, got again similar problem (although less now)
further investigation shows, there might problem network connection or proxy, weird, because bower install succeeds. anyhow, solution working quite me following:
- use native npm install build step visual studio online first step
- add environment variable build service in order identify in script, it's running on build server (i called
vso, assigned value 1) check in script if it's running on build server or not, in powershell can this:
if ($env:vso -ne 1) { echo "npm install" npm install }
Comments
Post a Comment