当前位置: 首页 > 面试题库 >

Node.js:由于node-sass和node-gyp而找不到Python异常

阙项禹
2023-03-14
问题内容

突然在我的jenkins环境之一中,构建开始失败,而在本地计算机中,由于安装了python,它似乎运行良好,

从日志中我能检测到的问题是内部的依赖是 节点GYP V3.5.0节点萨斯v3.8.0
当我访问研究,这约节点GYP,发现先决条件的Python需要安装。

所以我的问题是,我可以安装哪个版本的node-sass来绕过此进程,或者有更好的解决方案,因为直到今天早上我的构建在同一环境上都可以正常运行。

节点v5.10.1

错误日志

gyp verb check python checking for Python executable "python2" in the PATH
gyp verb `which` failed Error: not found: python2
gyp verb `which` failed     at getNotFoundError (C:\Program Files (x86)\Jenkins\jobs\NdbSite-hot-fix-Manual-PreBuild\workspace\src\NdbSite.UI\node_modules\which\which.js:13:12)
gyp verb `which` failed     at F (C:\Program Files (x86)\Jenkins\jobs\NdbSite-hot-fix-Manual-PreBuild\workspace\src\NdbSite.UI\node_modules\which\which.js:68:19)
gyp verb `which` failed     at E (C:\Program Files (x86)\Jenkins\jobs\NdbSite-hot-fix-Manual-PreBuild\workspace\src\NdbSite.UI\node_modules\which\which.js:80:29)
gyp verb `which` failed     at C:\Program Files (x86)\Jenkins\jobs\NdbSite-hot-fix-Manual-PreBuild\workspace\src\NdbSite.UI\node_modules\which\which.js:89:16
gyp verb `which` failed     at C:\Program Files (x86)\Jenkins\jobs\NdbSite-hot-fix-Manual-PreBuild\workspace\src\NdbSite.UI\node_modules\isexe\index.js:44:5
gyp verb `which` failed     at C:\Program Files (x86)\Jenkins\jobs\NdbSite-hot-fix-Manual-PreBuild\workspace\src\NdbSite.UI\node_modules\isexe\windows.js:29:5
gyp verb `which` failed     at FSReqWrap.oncomplete (fs.js:82:15)
gyp verb `which` failed  python2 { [Error: not found: python2] code: 'ENOENT' }
gyp verb check python checking for Python executable "python" in the PATH
gyp verb `which` failed Error: not found: python
gyp verb `which` failed     at getNotFoundError (C:\Program Files (x86)\Jenkins\jobs\NdbSite-hot-fix-Manual-PreBuild\workspace\src\NdbSite.UI\node_modules\which\which.js:13:12)
gyp verb `which` failed     at F (C:\Program Files (x86)\Jenkins\jobs\NdbSite-hot-fix-Manual-PreBuild\workspace\src\NdbSite.UI\node_modules\which\which.js:68:19)
gyp verb `which` failed     at E (C:\Program Files (x86)\Jenkins\jobs\NdbSite-hot-fix-Manual-PreBuild\workspace\src\NdbSite.UI\node_modules\which\which.js:80:29)
gyp verb `which` failed     at C:\Program Files (x86)\Jenkins\jobs\NdbSite-hot-fix-Manual-PreBuild\workspace\src\NdbSite.UI\node_modules\which\which.js:89:16
gyp verb `which` failed     at C:\Program Files (x86)\Jenkins\jobs\NdbSite-hot-fix-Manual-PreBuild\workspace\src\NdbSite.UI\node_modules\isexe\index.js:44:5
gyp verb `which` failed     at C:\Program Files (x86)\Jenkins\jobs\NdbSite-hot-fix-Manual-PreBuild\workspace\src\NdbSite.UI\node_modules\isexe\windows.js:29:5
gyp verb `which` failed     at FSReqWrap.oncomplete (fs.js:82:15)
gyp verb `which` failed  python { [Error: not found: python] code: 'ENOENT' }
gyp verb could not find "python". checking python launcher 
gyp verb could not find "python". guessing location 
gyp verb ensuring that file exists: C:\Python27\python.exe
gyp ERR! configure error 
gyp ERR! stack Error: Can't find Python executable "python", you can set the PYTHON env variable.
gyp ERR! stack     at Object.failNoPython (C:\Program Files (x86)\Jenkins\jobs\NdbSite-hot-fix-Manual-PreBuild\workspace\src\NdbSite.UI\node_modules\node-gyp\lib\configure.js:454:19)
gyp ERR! stack     at Object.<anonymous> (C:\Program Files (x86)\Jenkins\jobs\NdbSite-hot-fix-Manual-PreBuild\workspace\src\NdbSite.UI\node_modules\node-gyp\lib\configure.js:480:16)
gyp ERR! stack     at C:\Program Files (x86)\Jenkins\jobs\NdbSite-hot-fix-Manual-PreBuild\workspace\src\NdbSite.UI\node_modules\graceful-fs\polyfills.js:284:29
gyp ERR! stack     at FSReqWrap.oncomplete (fs.js:82:15)
gyp ERR! System Windows_NT 6.3.9600
gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files (x86)\\Jenkins\\jobs\\NdbSite-hot-fix-Manual-PreBuild\\workspace\\src\\NdbSite.UI\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild" "--verbose" "--libsass_ext=" "--libsass_cflags=" "--libsass_ldflags=" "--libsass_library="
gyp ERR! cwd C:\Program Files (x86)\Jenkins\jobs\NdbSite-hot-fix-Manual-PreBuild\workspace\src\NdbSite.UI\node_modules\node-sass
gyp ERR! node -v v5.10.1
gyp ERR! node-gyp -v v3.5.0
gyp ERR! not ok 
Build failed

任何想法都非常感谢,谢谢。


问题答案:

安装时,Node-sass会尝试为您的平台下载二进制文件。3.8支持节点5 https://github.com/sass/node-
sass/releases/tag/v3.8.0
如果您的Jenkins无法下载预构建的二进制文件,那么您需要遵循Node-
gyp上的平台要求自述文件(Python2,VS或MSBuild,…)如果可能的话,我建议将您的Node更新到至少6,因为Node不再支持5。如果要升级到8,则需要将node-
sass更新为4.5.3



 类似资料:
  • 突然,在我的一个jenkins环境构建开始失败,而在本地机器中,它似乎工作正常,因为我安装了python, 从日志中,我能够检测到问题是内部依赖,即node-gyp v3.5.0从node-sass v3.8.0当我通过访问这个关于node-gyp的研究,并发现需要安装Python的先决条件。 所以我的问题是,我可以安装哪个版本的node sass来绕过这个问题,还是有更好的解决方案,因为我的构建

  • 当我用Angular在我的项目上安装npm时。节点sass/node gyp安装失败,错误显示如下: $npm安装 节点-sass@4.10.0安装C:\Users\d\Documents\project\app\node\u modules\node sass node scripts/install.js 从https://github.com/sass/node-sass/releases/

  • 问题内容: 我正在尝试使用安装模块。但是它总是会出错。这是错误: 我一直在搜索它,通常说它是关于。我的节点是v10.16.0。我还安装了Python 2.7。我的vs版本是2019。 确实,这仅与模块有关。如果是这样,是否还有其他解决方案可在Node.js中预览png等文件 编辑 我已卸载VS2019并安装了VS2017 Build Tools。但是仍然给出另一个错误: 问题答案: 我过去也遇到过

  • config:macOS High Sierra,version 10.13.2,node:v8.1.2 npm:5.0.3当我在angularjs项目中运行npm start时,我得到以下错误: 在此之后我运行: 现在我得到了这个错误: 为什么npm不安装Node-Sass?如何安装Node-Sass?

  • 问题内容: 配置:macOS High Sierra,版本10.13.2,节点:v8.1.2 npm:5.0.3在我的angularjs项目中运行npm start时,出现以下错误: 之后,我运行: 现在我得到这个错误: 为什么npm不安装node-sass?如何安装node-sass? 问题答案: 解决方法如下: 请享用!

  • 在 v4.3.0之前本项目都是基于node-sass进行构建的,但node-sass底层依赖 libsass,导致很多用户安装的特别的困难,尤其是 windows 用户,它强制用户在windows环境中必须安装python2和Visual Studio才能编译成功。 所以为了解决这个问题,本项目在 v4.3.0修改为dart-sass进行构建,它能在保证性能的前提下大大简化用户的安装成本。通过这个