npm安装使用节点gyp从CLI工作,从TeamCity失败
我被TeamCity的一个不可靠的构建所困扰npm安装使用节点gyp从CLI工作,从TeamCity失败,npm,teamcity,node-gyp,Npm,Teamcity,Node Gyp,我被TeamCity的一个不可靠的构建所困扰 当为间接使用node gyp编译解决方案的项目执行npm安装时,至关重要的是,只有在从TeamCity代理执行时才会失败 [回答后编辑]执行的上下文来自构建步骤,该步骤执行自定义的Build.ps1,该步骤自动化构建过程,包括c#、npm项目、执行单元测试等。这意味着它不是TeamCity中的一系列离散步骤,而是可以从任何环境执行的单个PowerShell命令 如果我在TeamCity代理运行的同一台服务器上的同一个用户下从命令行执行,那么它可以正常
node gyp
编译解决方案的项目执行npm安装时,至关重要的是,只有在从TeamCity代理执行时才会失败
Build.ps1
,该步骤自动化构建过程,包括c#、npm项目、执行单元测试等。这意味着它不是TeamCity中的一系列离散步骤,而是可以从任何环境执行的单个PowerShell命令MSBuild: C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\Bin\MSBuild.exe
Executing Build
configuration: debug
Restoring npm for src\my-corp-app
> scrypt@6.0.3 preinstall D:\IR\my-corp-app\TcBuild\src\my-corp-app\node_modules\scrypt
> node node-scrypt-preinstall.js
> keccak@1.4.0 install D:\IR\my-corp-app\TcBuild\src\my-corp-app\node_modules\keccak
> npm run rebuild || echo "Keccak bindings compilation fail. Pure JS implementation will be used."
> keccak@1.4.0 rebuild D:\IR\my-corp-app\TcBuild\src\my-corp-app\node_modules\keccak
> node-gyp rebuild
D:\IR\my-corp-app\TcBuild\src\my-corp-app\node_modules\keccak>if not defined npm_config_node_gyp (node "C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\node-gyp-bin\\..\..\node_modules\node-gyp\bin\node-gyp.js" rebuild ) else (node "C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js" rebuild )
Building the projects in this solution one at a time. To enable parallel build, please add the "/m" switch.
D:\IR\my-corp-app\TcBuild\src\my-corp-app\node_modules\keccak\build\keccak.vcxproj(21,3): error MSB4019: The imported project "D:\Microsoft.Cpp.Default.props" was not found. Confirm that the path in the <Import> declaration is correct, and that the file exists on disk.
gyp ERR! build error
gyp ERR! stack Error: `msbuild` failed with exit code: 1
gyp ERR! stack at ChildProcess.onExit (C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\build.js:262:23)
gyp ERR! stack at emitTwo (events.js:126:13)
gyp ERR! stack at ChildProcess.emit (events.js:214:7)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:198:12)
gyp ERR! System Windows_NT 10.0.14393
gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild"
gyp ERR! cwd D:\IR\my-corp-app\TcBuild\src\my-corp-app\node_modules\keccak
gyp ERR! node -v v8.12.0
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! keccak@1.4.0 rebuild: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the keccak@1.4.0 rebuild script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm WARN Local package.json exists, but node_modules missing, did you mean to install?
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\teamcity_user\AppData\Roaming\npm-cache\_logs\2019-02-13T11_38_48_872Z-debug.log
"Keccak bindings compilation fail. Pure JS implementation will be used."
通过添加一个插入额外(和冗余)PowerShell构建步骤,最终解决了此问题:
- 流道类型:
PowerShell
- 脚本:
SourceCode
- 工作目录:
- 脚本源:
npm安装
build.ps1
的深层执行npm安装了
出于某种原因,上述方法有效,而埋藏的方法无效。我无法解释为什么。确认执行文件夹正确,并从两个上下文中使用了get command npm
,两个上下文的结果相同:
CommandType Name Version Source
----------- ---- ------- ------
Application npm.cmd 0.0.0.0 C:\Program Files\nodejs\npm.cmd
通过添加一个插入额外(和冗余)PowerShell构建步骤,最终解决了此问题:
- 流道类型:
PowerShell
- 脚本:
SourceCode
- 工作目录:
- 脚本源:
npm安装
它神奇地工作了
现在,当然我已经在我的构建自动化build.ps1
的深层执行npm安装了
出于某种原因,上述方法有效,而埋藏的方法无效。我无法解释为什么。确认执行文件夹正确,并从两个上下文中使用了get command npm
,两个上下文的结果相同:
CommandType Name Version Source
----------- ---- ------- ------
Application npm.cmd 0.0.0.0 C:\Program Files\nodejs\npm.cmd
我也在同一条船上。npm是否在文件系统中删除builderror.log?对我来说确实如此,这导致我发现错误“error C2039:'ForceSet':不是'v8::Object'的成员”。我编辑了这个问题以显示完整的日志-但是没有具有确切名称的文件builderror.log
。一半的人想知道我的%PATH%是否太长,但它只有1700个字符,限制是2048个字符。我在同一条船上。npm是否在文件系统中删除builderror.log?对我来说确实如此,这导致我发现错误“error C2039:'ForceSet':不是'v8::Object'的成员”。我编辑了这个问题以显示完整的日志-但是没有具有确切名称的文件builderror.log
。一半的人想知道我的%PATH%是否太长,但它只有1700个字符,限制是2048个。不幸的是,我没有那么幸运。对于傻笑,我也试过同样的方法。我在新的冗余步骤中遇到了相同的错误。我还想知道您是否在命令行中发出了“节点重建”,您会看到TeamCity服务遇到的相同错误。不幸的是,我没有那么幸运。对于傻笑,我也试过同样的方法。我在新的冗余步骤中遇到了相同的错误。我还想知道您是否在命令行中发出了“节点重建”,您会看到TeamCity服务遇到的相同错误。