【问题标题】:npm install complains 'node' is not recognized as an internal or external command while node is in the path当节点在路径中时,npm install 抱怨“节点”不被识别为内部或外部命令
【发布时间】:2019-02-05 20:48:38
【问题描述】:

我现在正在构建 Jenkins,但在执行“npm install”时,我收到一条错误消息,提示“'node' 未被识别为内部或外部命令、可运行程序或批处理文件。”但是,我的路径中确实有节点,并且我已经验证了这一点,但在 npm 安装之前执行“where node”。

“where node”和“npm install”都位于我的 Jenkins 作业的同一个执行 Windows 批处理命令部分。

我已经阅读了一些帖子。有时会遇到此错误,因为未正确处理路径内的空格。我的路径中没有空间。

我也无法方便地访问构建环境的机器。我只能尝试 Jenkins 的 Execute Windows 批处理命令。

以下是我的构建日志,包括错误消息。

npm install 
14:48:56 npm WARN deprecated ng2-bootstrap@1.6.3: ng2-bootstrap is renamed to ngx-bootstrap, please do npm i ngx-bootstrap -S
14:48:57 npm WARN deprecated hapi@13.5.3: This version is no longer maintained. Please upgrade to the latest version of the framework.
14:48:58 npm WARN deprecated gulp-util@3.0.7: gulp-util is deprecated - replace it, following the guidelines at https://medium.com/gulpjs/gulp-util-ca3b1f9f9ac5
14:48:59 npm WARN deprecated joi@8.1.1: This version is no longer maintained. Please upgrade to the latest version.
14:48:59 npm WARN deprecated joi@10.6.0: This version is no longer maintained. Please upgrade to the latest version.
14:48:59 npm WARN deprecated boom@3.2.2: This version is no longer maintained. Please upgrade to the latest version.
14:48:59 npm WARN deprecated joi@8.4.2: This version is no longer maintained. Please upgrade to the latest version.
14:48:59 npm WARN deprecated call@3.0.4: This version is no longer maintained. Please upgrade to the latest version.
14:48:59 npm WARN deprecated kilt@2.0.2: This module is no longer maintained.
14:48:59 npm WARN deprecated hoek@3.0.4: This version is no longer maintained. Please upgrade to the latest version.
14:48:59 npm WARN deprecated peekaboo@2.0.2: This module is no longer maintained.
14:48:59 npm WARN deprecated statehood@4.1.0: This version is no longer maintained. Please upgrade to the latest version.
14:48:59 npm WARN deprecated subtext@4.4.1: This version is no longer maintained. Please upgrade to the latest version.
14:48:59 npm WARN deprecated fast-safe-stringify@1.0.9: use 1.1.0+ see https://github.com/davidmarkclements/fast-safe-stringify/issues/4
14:48:59 npm WARN deprecated browserslist@1.7.7: Browserslist 2 could fail on reading Browserslist >3.0 config used in other tools.
14:49:00 npm WARN deprecated boom@4.3.1: This version is no longer maintained. Please upgrade to the latest version.
14:49:00 npm WARN deprecated joi@9.2.0: This version is no longer maintained. Please upgrade to the latest version.
14:49:05 npm WARN deprecated boom@3.2.0: This version is no longer maintained. Please upgrade to the latest version.
14:49:05 npm WARN deprecated call@3.0.2: This version is no longer maintained. Please upgrade to the latest version.
14:49:05 npm WARN deprecated joi@8.1.0: This version is no longer maintained. Please upgrade to the latest version.
14:49:05 npm WARN deprecated kilt@2.0.1: This module is no longer maintained.
14:49:05 npm WARN deprecated peekaboo@2.0.1: This module is no longer maintained.
14:49:05 npm WARN deprecated statehood@4.0.1: This version is no longer maintained. Please upgrade to the latest version.
14:49:05 npm WARN deprecated subtext@4.0.3: This version is no longer maintained. Please upgrade to the latest version.
14:49:05 npm WARN deprecated wreck@7.2.1: This version is no longer maintained. Please upgrade to the latest version.
14:55:08 
14:55:08 > node-sass@4.5.3 install F:\JENKINS-SLAVE\workspace\some_appcode\jenkins_job_code\app_folder\node_modules\node-sass
14:55:08 > node scripts/install.js
14:55:08 
14:55:08 'node' is not recognized as an internal or external command,
14:55:08 operable program or batch file.

【问题讨论】:

  • 詹金斯工作中where node 的输出是什么?
  • 这个:F:\JENKINS-SLAVE\tools\jenkins.plugins.nodejs.tools.NodeJSInstallation\NodeJS-Windows-v8.2.1\node.exe

标签: node.js node-sass


【解决方案1】:

在控制面板 -> 系统 -> 高级系统设置下将 nodejs 新系统变量添加到您的 PC

;C:\Program Files\nodejs\

之后,重新运行命令:

npm

【讨论】:

    【解决方案2】:

    实际的解决方案是清除 Jenkins 虚拟机的缓存,它会起作用。这是 Jenkins 的缓存问题。

    【讨论】:

      猜你喜欢
      • 2020-10-24
      • 1970-01-01
      • 2022-01-07
      • 2014-11-26
      • 1970-01-01
      • 2013-03-07
      • 2019-01-25
      • 2018-10-19
      • 1970-01-01
      相关资源
      最近更新 更多