Azure DevOps npm 安装失败,节点 sass 4.9.0 出现 post 安装脚本错误

Azure DevOps npm install fails with post install script errors for node-sass 4.9.0

我正在尝试 运行 构建。自上次构建 运行(大约 5 个月前)以来,我做了非常小的更改,但现在我无法通过 npm install.

这是日志的一些摘录 - 我会 post 更多但不会让我这么大...

2020-01-29T13:32:00.3347468Z ##[section]Starting: npm install
2020-01-29T13:32:00.3445773Z ==============================================================================
2020-01-29T13:32:00.3445826Z Task         : npm
2020-01-29T13:32:00.3445864Z Description  : Install and publish npm packages, or run an npm command. Supports npmjs.com and authenticated registries like Azure Artifacts.
2020-01-29T13:32:00.3445892Z Version      : 1.161.0
2020-01-29T13:32:00.3445917Z Author       : Microsoft Corporation
2020-01-29T13:32:00.3445967Z Help         : https://docs.microsoft.com/azure/devops/pipelines/tasks/package/npm
2020-01-29T13:32:00.3445994Z ==============================================================================
2020-01-29T13:32:00.7920586Z SYSTEMVSSCONNECTION exists true
2020-01-29T13:32:00.9489042Z SYSTEMVSSCONNECTION exists true
2020-01-29T13:32:01.3438318Z [command]C:\windows\system32\cmd.exe /D /S /C ""C:\Program Files\nodejs\npm.cmd" --version"
2020-01-29T13:32:11.3468119Z 6.13.4
2020-01-29T13:32:13.4260298Z [command]C:\windows\system32\cmd.exe /D /S /C ""C:\Program Files\nodejs\npm.cmd" config list"
2020-01-29T13:32:13.9747579Z ; cli configs
2020-01-29T13:32:13.9748043Z metrics-registry = "https://registry.npmjs.org/"
2020-01-29T13:32:13.9748226Z scope = ""
2020-01-29T13:32:13.9748386Z user-agent = "npm/6.13.4 node/v12.14.1 win32 x64"
2020-01-29T13:32:13.9748504Z 
2020-01-29T13:32:13.9748640Z ; environment configs
2020-01-29T13:32:13.9748792Z cache = "C:\npm\cache"
2020-01-29T13:32:13.9748951Z prefix = "C:\npm\prefix"
2020-01-29T13:32:13.9749077Z userconfig = "D:\a\1\npm\124.npmrc"
2020-01-29T13:32:13.9749211Z 
2020-01-29T13:32:13.9749338Z ; builtin config undefined
2020-01-29T13:32:13.9749449Z 
2020-01-29T13:32:13.9749576Z ; node bin location = C:\Program Files\nodejs\node.exe
2020-01-29T13:32:13.9749724Z ; cwd = D:\a\s\src\Ministryweb
2020-01-29T13:32:13.9749849Z ; HOME = C:\Users\VssAdministrator
2020-01-29T13:32:13.9750000Z ; "npm config ls -l" to show all defaults.
2020-01-29T13:32:13.9750146Z 
2020-01-29T13:32:13.9803873Z [command]C:\windows\system32\cmd.exe /D /S /C ""C:\Program Files\nodejs\npm.cmd" install"
2020-01-29T13:34:15.6513894Z 
2020-01-29T13:34:15.6514788Z > node-sass@4.9.0 install D:\a\s\src\Ministryweb\node_modules\node-sass
2020-01-29T13:34:15.6514976Z > node scripts/install.js
2020-01-29T13:34:15.6515158Z 
2020-01-29T13:34:15.6515339Z Downloading binary from https://github.com/sass/node-sass/releases/download/v4.9.0/win32-x64-72_binding.node
2020-01-29T13:34:15.6515564Z 
2020-01-29T13:34:15.6515739Z > node-sass@4.9.0 postinstall D:\a\s\src\Ministryweb\node_modules\node-sass
2020-01-29T13:34:15.6515874Z > node scripts/build.js
2020-01-29T13:34:15.6515991Z 
2020-01-29T13:34:15.6516160Z Building: C:\Program Files\nodejs\node.exe D:\a\s\src\Ministryweb\node_modules\node-gyp\bin\node-gyp.js rebuild --verbose --libsass_ext= --libsass_cflags= --libsass_ldflags= --libsass_library=
2020-01-29T13:34:15.6516306Z Building the projects in this solution one at a time. To enable parallel build, please add the "/m" switch.
2020-01-29T13:34:15.6516469Z Build started 1/29/2020 1:32:48 PM.
2020-01-29T13:34:15.6516640Z Project "D:\a\s\src\Ministryweb\node_modules\node-sass\build\binding.sln" on node 1 (default targets).
2020-01-29T13:34:15.6516772Z ValidateSolutionConfiguration:
2020-01-29T13:34:15.6516907Z   Building solution configuration "Release|x64".
2020-01-29T13:34:15.6517083Z Project "D:\a\s\src\Ministryweb\node_modules\node-sass\build\binding.sln" (1) is building "D:\a\s\src\Ministryweb\node_modules\node-sass\build\binding.vcxproj.metaproj" (2) on node 1 (default targets).
2020-01-29T13:34:15.6517456Z Project "D:\a\s\src\Ministryweb\node_modules\node-sass\build\binding.vcxproj.metaproj" (2) is building "D:\a\s\src\Ministryweb\node_modules\node-sass\build\src\libsass.vcxproj" (3) on node 1 (default targets).
2020-01-29T13:34:15.6517700Z PrepareForBuild:
2020-01-29T13:34:15.6517847Z   Creating directory "Release\obj\libsass\".
2020-01-29T13:34:15.6519124Z   Creating directory "D:\a\s\src\Ministryweb\node_modules\node-sass\build\Release\".
2020-01-29T13:34:15.6519299Z   Creating directory "Release\obj\libsass\libsass.tlog\".
2020-01-29T13:34:15.6519429Z InitializeBuildStatus:
2020-01-29T13:34:15.6519566Z   Creating "Release\obj\libsass\libsass.tlog\unsuccessfulbuild" because "AlwaysCreate" was specified.
2020-01-29T13:34:15.6519727Z ClCompile:
2020-01-29T13:34:15.6520514Z   C:\Program Files (x86)\Microsoft Visual Studio17\Enterprise\VC\Tools\MSVC.16.27023\bin\HostX64\x64\CL.exe /c /I"C:\Users\VssAdministrator\.node-gyp.14.1\include\node" /I"C:\Users\VssAdministrator\.node-gyp.14.1\src" /I"C:\Users\VssAdministrator\.node-gyp.14.1\deps\uv\include" /I"C:\Users\VssAdministrator\.node-gyp.14.1\deps\v8\include" /I..\..\src\libsass\include /Z7 /nologo /W3 /WX- /diagnostics:classic /MP /Ox /Ob2 /Oi /Ot /Oy /D NODE_GYP_MODULE_NAME=libsass /D USING_UV_SHARED=1 /D USING_V8_SHARED=1 /D V8_DEPRECATION_WARNINGS=1 /D V8_DEPRECATION_WARNINGS /D V8_IMMINENT_DEPRECATION_WARNINGS /D WIN32 /D _CRT_SECURE_NO_DEPRECATE /D _CRT_NONSTDC_NO_DEPRECATE /D _HAS_EXCEPTIONS=0 /D OPENSSL_NO_PINSHARED /D OPENSSL_THREADS /D "LIBSASS_VERSION=\"3.5.4\"" /GF /Gm- /MT /GS /Gy /fp:precise /Qspectre /Zc:wchar_t /Zc:forScope /Zc:inline /GR- /Fo"Release\obj\libsass\" /Fd"Release\obj\libsass\libsass.pdb" /Gd /TP /wd4351 /wd4355 /wd4800 /wd4251 /wd4275 /wd4244 /wd4267 /FC /errorReport:queue /GR /EHsc ..\..\src\libsass\src\ast.cpp ..\..\src\libsass\src\ast_fwd_decl.cpp ..\..\src\libsass\src\backtrace.cpp ..\..\src\libsass\src\base64vlq.cpp ..\..\src\libsass\src\bind.cpp ..\..\src\libsass\src\check_nesting.cpp ..\..\src\libsass\src\color_maps.cpp ..\..\src\libsass\src\constants.cpp ..\..\src\libsass\src\context.cpp ..\..\src\libsass\src\cssize.cpp ..\..\src\libsass\src\emitter.cpp ..\..\src\libsass\src\environment.cpp ..\..\src\libsass\src\error_handling.cpp ..\..\src\libsass\src\eval.cpp ..\..\src\libsass\src\expand.cpp ..\..\src\libsass\src\extend.cpp ..\..\src\libsass\src\file.cpp ..\..\src\libsass\src\functions.cpp ..\..\src\libsass\src\inspect.cpp ..\..\src\libsass\src\json.cpp ..\..\src\libsass\src\lexer.cpp ..\..\src\libsass\src\listize.cpp ..\..\src\libsass\src\memory\SharedPtr.cpp ..\..\src\libsass\src\node.cpp ..\..\src\libsass\src\operators.cpp ..\..\src\libsass\src\output.cpp ..\..\src\libsass\src\parser.cpp ..\..\src\libsass\src\plugins.cpp ..\..\src\libsass\src\position.cpp ..\..\src\libsass\src\prelexer.cpp ..\..\src\libsass\src\remove_placeholders.cpp ..\..\src\libsass\src\sass.cpp ..\..\src\libsass\src\sass2scss.cpp ..\..\src\libsass\src\sass_context.cpp ..\..\src\libsass\src\sass_functions.cpp ..\..\src\libsass\src\sass_util.cpp ..\..\src\libsass\src\sass_values.cpp ..\..\src\libsass\src\source_map.cpp ..\..\src\libsass\src\subset_map.cpp ..\..\src\libsass\src\to_c.cpp ..\..\src\libsass\src\to_value.cpp ..\..\src\libsass\src\units.cpp ..\..\src\libsass\src\utf8_string.cpp ..\..\src\libsass\src\util.cpp ..\..\src\libsass\src\values.cpp
2020-01-29T13:34:15.6521162Z cl : Command line warning D9025: overriding '/GR-' with '/GR' [D:\a\s\src\Ministryweb\node_modules\node-sass\build\src\libsass.vcxproj]
2020-01-29T13:34:15.6521358Z cl : Command line warning D9025: overriding '/GR-' with '/GR' [D:\a\s\src\Ministryweb\node_modules\node-sass\build\src\libsass.vcxproj]
2020-01-29T13:34:15.6521493Z   ast.cpp
2020-01-29T13:34:15.6521625Z cl : Command line warning D9025: overriding '/GR-' with '/GR' [D:\a\s\src\Ministryweb\node_modules\node-sass\build\src\libsass.vcxproj]
-- ABBREVIATED --
2020-01-29T13:34:15.7628892Z 11784 silly postinstall sass-graph@2.2.4
2020-01-29T13:34:15.7628923Z 11785 info lifecycle sass-graph@2.2.4~postinstall: sass-graph@2.2.4
2020-01-29T13:34:15.7628952Z 11786 silly postinstall node-sass@4.9.0
2020-01-29T13:34:15.7628986Z 11787 info lifecycle node-sass@4.9.0~postinstall: node-sass@4.9.0
2020-01-29T13:34:15.7629016Z 11788 verbose lifecycle node-sass@4.9.0~postinstall: unsafe-perm in lifecycle true
2020-01-29T13:34:15.7629354Z 11789 verbose lifecycle node-sass@4.9.0~postinstall: PATH: C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\node-gyp-bin;D:\a\s\src\Ministryweb\node_modules\node-sass\node_modules\.bin;D:\a\s\src\Ministryweb\node_modules\.bin;C:\hostedtoolcache\windows\NuGet.4.1\x64;C:\agents.164.6\externals\git\cmd;C:/hostedtoolcache/windows\Python.6.8\x64;C:/hostedtoolcache/windows\Python.6.8\x64\Scripts;C:\Program Files\Mercurial\;C:\ProgramData\kind;C:\vcpkg;C:\cf-cli;C:\Program Files (x86)\NSIS\;C:\Program Files\Mercurial\;C:\Program Files\Boost.69.0;C:\Program Files\dotnet;C:\mysql-5.7.21-winx64\bin;C:\Program Files\Java\zulu-8-azure-jdk_8.40.0.25-8.0.222-win_x64\bin;C:\Program Files (x86)\sbt\bin;C:\Rust\.cargo\bin;C:\hostedtoolcache\windows\Ruby.5.7\x64\bin;C:\Go1.12.7\bin;C:\hostedtoolcache\windows\Python.6.8\x64\Scripts;C:\hostedtoolcache\windows\Python.6.8\x64;C:\npm\prefix;C:\Program Files (x86)\Microsoft SDKs\Azure\CLI2\wbin;C:\Program Files\Microsoft MPI\Bin\;C:\windows\system32;C:\windows;C:\windows\System32\Wbem;C:\windows\System32\WindowsPowerShell\v1.0\;C:\ProgramData\Chocolatey\bin;C:\Program Files\Docker;C:\Program Files\PowerShell\;C:\Program Files\dotnet\;C:\Program Files\Microsoft SQL Server0\Tools\Binn\;C:\Program Files (x86)\Microsoft SQL Server0\DTS\Binn\;C:\Program Files (x86)\Microsoft SQL Server0\DTS\Binn\;C:\Program Files (x86)\Microsoft SQL Server0\DTS\Binn\;C:\Program Files (x86)\Microsoft SQL Server0\DTS\Binn\;C:\Program Files (x86)\Microsoft SQL Server0\DTS\Binn\;C:\Program Files (x86)\Windows Kits\Windows Performance Toolkit\;C:\Program Files\Microsoft Service Fabric\bin\Fabric\Fabric.Code;C:\Program Files\Microsoft SDKs\Service Fabric\Tools\ServiceFabricLocalClusterManager;C:\Program Files\nodejs\;C:\Program Files\Git\cmd;C:\Program Files\Git\mingw64\bin;C:\Program Files\Git\usr\bin;c:\tools\php;C:\Program Files (x86)\sbt\bin;C:\Program Files (x86)\Subversion\bin;C:\SeleniumWebDrivers\ChromeDriver\;C:\ProgramData\chocolatey\lib\maven\apache-maven-3.6.2\bin;C:\Program Files\CMake\bin;C:\Strawberry\c\bin;C:\Strawberry\perl\site\bin;C:\Strawberry\perl\bin;C:\Program Files\OpenSSL\bin;C:\Users\VssAdministrator\.dotnet\tools;C:\Program Files (x86)\Microsoft SQL Server
2020-01-29T13:34:15.7629678Z 11790 verbose lifecycle node-sass@4.9.0~postinstall: CWD: D:\a\s\src\Ministryweb\node_modules\node-sass
2020-01-29T13:34:15.7629714Z 11791 silly lifecycle node-sass@4.9.0~postinstall: Args: [ '/d /s /c', 'node scripts/build.js' ]
2020-01-29T13:34:15.7629751Z 11792 silly lifecycle node-sass@4.9.0~postinstall: Returned: code: 1  signal: null
2020-01-29T13:34:15.7629793Z 11793 info lifecycle node-sass@4.9.0~postinstall: Failed to exec postinstall script
2020-01-29T13:34:15.7629823Z 11794 timing action:postinstall Completed in 95942ms
2020-01-29T13:34:15.7629857Z 11795 verbose unlock done using C:\npm\cache\_locks\staging-30fa0784d58eff0a.lock for D:\a\s\src\Ministryweb\node_modules\.staging
2020-01-29T13:34:15.7629894Z 11796 timing stage:rollbackFailedOptional Completed in 628ms
2020-01-29T13:34:15.7629930Z 11797 timing stage:runTopLevelLifecycles Completed in 114608ms
-- ABBREVIATED --
2020-01-29T13:34:15.7646802Z 11798 silly saveTree `-- node-sass@4.9.0
2020-01-29T13:34:15.7646831Z 11799 verbose stack Error: node-sass@4.9.0 postinstall: `node scripts/build.js`
2020-01-29T13:34:15.7646859Z 11799 verbose stack Exit status 1
2020-01-29T13:34:15.7646897Z 11799 verbose stack     at EventEmitter.<anonymous> (C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\index.js:332:16)
2020-01-29T13:34:15.7646933Z 11799 verbose stack     at EventEmitter.emit (events.js:223:5)
2020-01-29T13:34:15.7646967Z 11799 verbose stack     at ChildProcess.<anonymous> (C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\lib\spawn.js:55:14)
2020-01-29T13:34:15.7647002Z 11799 verbose stack     at ChildProcess.emit (events.js:223:5)
2020-01-29T13:34:15.7647032Z 11799 verbose stack     at maybeClose (internal/child_process.js:1021:16)
2020-01-29T13:34:15.7647068Z 11799 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:283:5)
2020-01-29T13:34:15.7647101Z 11800 verbose pkgid node-sass@4.9.0
2020-01-29T13:34:15.7647129Z 11801 verbose cwd D:\a\s\src\Ministryweb
2020-01-29T13:34:15.7647157Z 11802 verbose Windows_NT 10.0.14393
2020-01-29T13:34:15.7647190Z 11803 verbose argv "C:\Program Files\nodejs\node.exe" "C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js" "install"
2020-01-29T13:34:15.7647228Z 11804 verbose node v12.14.1
2020-01-29T13:34:15.7647255Z 11805 verbose npm  v6.13.4
2020-01-29T13:34:15.7647282Z 11806 error code ELIFECYCLE
2020-01-29T13:34:15.7647311Z 11807 error errno 1
2020-01-29T13:34:15.7647341Z 11808 error node-sass@4.9.0 postinstall: `node scripts/build.js`
2020-01-29T13:34:15.7647369Z 11808 error Exit status 1
2020-01-29T13:34:15.7647397Z 11809 error Failed at the node-sass@4.9.0 postinstall script.
2020-01-29T13:34:15.7647432Z 11809 error This is probably not a problem with npm. There is likely additional logging output above.
2020-01-29T13:34:15.7647466Z 11810 verbose exit [ 1, true ]
2020-01-29T13:34:15.7647484Z 
2020-01-29T13:34:15.7690666Z ##[error]Error: Npm failed with return code: 1
2020-01-29T13:34:15.7699335Z ##[section]Finishing: npm install

这似乎是编译 Python 代码时的一个错误,但除此之外,我在这里不知所措。任何想法为什么这可能突然开始失败?我能做些什么来修复它吗?

我正在使用 Azure 托管构建

我已经设法解决了这个问题。

出现这个问题似乎是因为构建过程使用了一个叫做 node_gyp 的东西。显然这在节点 11.x 之后停止工作并且节点 12 现在是 Azure DevOps 使用的默认节点(或在撰写本文时)。

我能够通过向管道添加构建步骤来安装节点来纠正问题 8.x - 之后一切正常。

看起来升级 node-sass 也应该修复它(但考虑到项目的年龄,这不是一个理想的解决方案)...

https://github.com/nodejs/node-gyp/issues/1763(link 有关底层 node-gyp 兼容性问题的更多信息)