python - Node.js 问题::Angular 未定义::找不到 bower 包::node gyp vs Python

标签 python angularjs node.js bower jhipster

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

Uncaught ReferenceError : 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.

我对以下方面进行了长时间的调查:

  • node_gyp 与 Python 问题
  • “找不到 bower 包”问题
  • “Angular 未定义”问题

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

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

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

提前感谢您的帮助!

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

最终解决方案

修复 node_gyp 与 Python 问题:

  • 降级到:Node.js 4.2.3 LTS 和 npm 2.14.7,
  • 安装Python 2.7.10和 Visual Studio Express (www.microsoft.com/en-gb/download/details.aspx?id=44914) (参见 node-gyp 依赖项:github.com/nodejs/node-gyp#installation)

修复“找不到 bower 包”问题和“未定义 Angular ”问题:

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

我的案例中缺少什么:

  • 安装 Git(git-scm.com/downloads)并使用以下命令将其设置为使用 https 而不是 git:git config --global url。"https://".insteadOf git://
  • 安装 Ruby(www.ruby-lang.org/) 并将其添加到 PATH
  • 使用 gem 安装 Sass:gem install sass 并将其添加到 PATH

最佳答案

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

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

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

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

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

关于python - Node.js 问题::Angular 未定义::找不到 bower 包::node gyp vs Python,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34399362/

相关文章:

java - Angular + Spring,$http 和 $location 获取项目名称

javascript - 在 Angular ng-grid 中如何指定子数组的计数

node.js - npm cors 包不工作

Python 访问字典并更改值 - 错误

python - 我的代码需要 gen.sleep 来执行异步函数吗?

angularjs - 在 Angular 中编写自定义控件或小部件

使用 Open SSL 生成 RSA key 的 Node.js 函数

javascript - String.fromCharCode 在浏览器和 Nodejs 之间得到不同的结果

python - 在 Python 中,如何判断模块是否来自 C 扩展?

python - 使用 Selenium 和 Python 在网站页面上迭代和收集数据