我运行应用程序时,我的本地服务器无法找到bower文件

时间:2018-05-10 20:39:06

标签: node.js npm gulp polymer bower

我必须从本地仓库运行一个应用程序(称为exoplanet-explorer)。我安装了Node.js和Git,我按照以下步骤操作:

在Git Bash的命令行中:

  git clone https://github.com/udacity/exoplanet.explorer.git
  cd exoplanet-explorer
  npm install -g gulp bower
  npm install && bower install
  gulp serve

当我运行gulp serve时,应用页面会打开,但它是空白的。在控制台中显示错误列表:

Failed to load resource: the server responded with a status of 404 (Not Found) webcomponents-lite.js:1 

(index):1 Refused to execute script from 'http://localhost:5000/bower_components/webcomponentsjs/webcomponents-lite.js' because its MIME type ('text/html') is not executable, and strict MIME type checking is enabled.

:5000/bower_components/iron-flex-layout/classes/iron-flex-layout.html:1 Failed to load resource: the server responded with a status of 404 (Not Found)   

:5000/bower_components/iron-pages/iron-pages.html:1 Failed to load resource: the server responded with a status of 404 (Not Found)

:5000/bower_components/iron-selector/iron-selector.html:1 Failed to load resource: the server responded with a status of 404 (Not Found)

:5000/bower_components/paper-material/paper-material.html:1 Failed to load resource: the server responded with a status of 404 (Not Found)

:5000/bower_components/paper-menu/paper-menu.html:1 Failed to load resource: the server responded with a status of 404 (Not Found)

:5000/bower_components/paper-scroll-header-panel/paper-scroll-header-panel.html:1 Failed to load resource: the server responded with a status of 404 (Not Found)

:5000/bower_components/paper-styles/paper-styles-classes.html:1 Failed to load resource: the server responded with a status of 404 (Not Found)

:5000/bower_components/paper-toolbar/paper-toolbar.html:1 Failed to load resource: the server responded with a status of 404 (Not Found)

[Deprecation] Styling master document from stylesheets defined in HTML Imports is deprecated, and is planned to be removed in M67, around May 2018. Please refer to  for possible migration paths.

page.js:1 Failed to load resource: the server responded with a status of 404 (Not Found)

(index):1 Refused to execute script from 

'http://localhost:5000/bower_components/page/page.js' because its MIME type ('text/html') is not executable, and strict MIME type checking is enabled.

:5000/bower_components/polymer/polymer.html:1 Failed to load resource: the server responded with a status of 404 (Not Found)

planet-thumb.html:78 Uncaught ReferenceError: Polymer is not defined
at planet-thumb.html:78
at planet-thumb.html:100

scale-visualizer.html:68 Uncaught ReferenceError: Polymer is not defined
at scale-visualizer.html:68
at scale-visualizer.html:189

我该怎么办?

1 个答案:

答案 0 :(得分:1)

我正在使用同一个项目,但使用Windows 10 Home,git版本2.15.1.windows.2和节点v8.11.3,npm v6.1.0,bower v1.8.4,gulp v3,却遇到了完全相同的问题.9.1。我查看了应该位于bower_components文件夹的位置,那里绝对没有任何内容。我还以管理员身份打开bash进行安装。

如果遇到这些错误,则出于任何原因,bower无法正确安装Polymer-starter-kit,或者您忘记/无法自行安装。我实际上看着安装失败,因为一遍又一遍地安装,键入“ bower list ”,它会告诉我所需的入门工具包中的聚合物文件,还没有安装-但我只看到文件已安装。

因此,在执行此操作之后,我必须执行“ bower install -f polymer-starter-kit ”,然后安装gulp并键入gulp才能使一切正常运行。希望这对其他人有帮助-昨天我花了16个小时,今天花了5个小时来解决这个问题。 注意:您可能要先进行“ 清除缓存缓存”。