Node.js 问题 :: Angular 未定义 :: 找不到凉亭包 :: node gyp vs Python

Node.js issue :: Angular is not defined :: cannot fined bower packages :: nodegyp vs Python

问题: 在浏览器中生成并启动我的新 jHipster API 后,我遇到了以下问题:

未捕获的引用错误:angular 未定义

之前那一代我装的是最新的:

生成期间,我收到以下警告和错误:

I'm all done. Running npm install & bower install for you to install the required dependencies. If this fails, try running the command yourself.

bufferutil@1.2.1 install K:\work\HP_AIC_WebAdmin_Customization\workspace\aicwebadminapi\node_modules\bufferutil node-gyp rebuild K:\work\HP_AIC_WebAdmin_Customization\workspace\aicwebadminapi\node_modules\bufferutil>if not defined npm_config_node_gyp (node "C:\Users\korban\AppData\Roaming\npm\node_modules\npm\bin\node-gyp-bin....\node_modules\node-gyp\bin\node-gyp.js" rebuild ) else (node rebuild ) 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 failNoPython (C:\Users\korban\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\lib\configure.js:401:14) gyp ERR! stack at C:\Users\korban\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\lib\configure.js:356:11 gyp ERR! stack at FSReqWrap.oncomplete (fs.js:82:15) gyp ERR! System Windows_NT 6.1.7601 gyp ERR! command "C:\Program Files\nodejs\node.exe" "C:\Users\korban\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js" "rebuild" gyp ERR! cwd K:\work\HP_AIC_WebAdmin_Customization\workspace\aicwebadminapi\node_modules\bufferutil gyp ERR! node -v v5.3.0 gyp ERR! node-gyp -v v3.2.1 gyp ERR! not ok npm WARN install:bufferutil@1.2.1 bufferutil@1.2.1 install: node-gyp rebuild npm WARN install:bufferutil@1.2.1 Exit status 1

utf-8-validate@1.2.1 install K:\work\HP_AIC_WebAdmin_Customization\workspace\aicwebadminapi\node_modules\utf-8-validate node-gyp rebuild K:\work\HP_AIC_WebAdmin_Customization\workspace\aicwebadminapi\node_modules\utf-8-validate>if not defined npm_config_node_gyp (node "C:\Users\korban\AppData\Roaming\npm\node_modules\npm\bin\node-gyp-bin....\node_modules\node-gyp\bin\node-gyp.js" rebuild ) else (node rebuild ) 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 failNoPython (C:\Users\korban\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\lib\configure.js:401:14) gyp ERR! stack at C:\Users\korban\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\lib\configure.js:356:11 gyp ERR! stack at FSReqWrap.oncomplete (fs.js:82:15) gyp ERR! System Windows_NT 6.1.7601 gyp ERR! command "C:\Program Files\nodejs\node.exe" "C:\Users\korban\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js" "rebuild" gyp ERR! cwd K:\work\HP_AIC_WebAdmin_Customization\workspace\aicwebadminapi\node_modules\utf-8-validate gyp ERR! node -v v5.3.0 gyp ERR! node-gyp -v v3.2.1 gyp ERR! not ok npm WARN install:utf-8-validate@1.2.1 utf-8-validate@1.2.1 install: node-gyp rebuild npm WARN install:utf-8-validate@1.2.1 Exit status 1 npm WARN optional Skipping failed optional dependency /chokidar/fsevents: npm WARN notsup Not compatible with your operating system or architecture: fsevents@1.0.6 bower angular-aria#1.4.8 ENOGIT git is not installed or not in the PATH Running "ngconstant:dev" (ngconstant) task Creating module aicwebadminapiApp at src/main/webapp/scripts/app/app.constants.js...OK

Running "wiredep:app" (wiredep) task Warning: Error: Cannot find where you keep your Bower packages. Use --force to continue.

Aborted due to warnings.

我对以下问题进行了长期调查

但我没有找到可行的解决方案。

注意: mvn clean install 和 mvn spring-boot:运行 已 运行 成功!

如果您对此有任何有用的想法可以分享,我将不胜感激!

提前感谢您的帮助!

@@@@@@@@@@@@@@@@@@@@@

最终解

修复 node_gyp 与 Python 问题:

修复“找不到 bower 包”问题和 "angular is not defined" 问题:

注意:首先使用rff-doctor(github.com/rakuten-frontend/rff-doctor)验证使用 Yeoman、G运行t 和 Bower 等的系统配置。它会告诉你缺少什么以及如何购买 it/them.

我的案例中缺少什么:

关于在 Windows 上设置 NodeJS 环境的一些建议:

  • 不要安装最新的 NodeJS 版本,而是安装最新的 LTS 版本(长期支持)
  • 还没有使用 npm 3
  • 不要使用深层项目文件夹路径(如 "K:\work\HP_AIC_WebAdmin_Customization\workspace\aicwebadminapi\"),因为 npm 可能会达到 Windows 最大路径长度 node_modules 内容。
  • 安装 Python 2.x 不是 3.x

考虑使用 nodist 或其他类似 nvm 的工具来安装节点。

您还必须解决 git 错误,Bower 需要 git 用于在 npm 注册表中找不到的某些模块。在重试 'bower install command' 之前,您必须通过安装 git 并确保 'git' 命令在您的路径中可用来修复您的环境。一些 git 已正确安装但无法工作,因为它被公司防火墙阻止。

您也可以尝试 运行 像 rff-doctor 这样的诊断工具来测试 git、g运行t、bower 和 node 的环境。不要遵循它关于 Ruby 和 SASS 的建议,因为 JHipster 不需要它们(它通过 grunt/gulp 使用 libsass)。