【问题标题】:Why is this GET-request not finding my script?为什么这个 GET 请求没有找到我的脚本?
【发布时间】:2016-10-23 13:36:27
【问题描述】:

尝试使用 npm 和 grunt 设置页面时出现错误。

Request URL:http://localhost:9997/bower_components/requirejs/require.js
Request Method:GET
Status Code:404 Not Found

遇到问题的 html 如下所示:

<script>
            var require = {
                baseUrl: '/',
                paths: {
                    'underscore': '/bower_components/underscore/underscore',
                    'backbone': '/bower_components/backbone/backbone',
                    'jquery': '/bower_components/jquery/dist/jquery',
                    'react': '/bower_components/react/react',
                    'mustache': '/bower_components/mustache/mustache',
                    'mySite-assets': '.'
                }
            };
        </script>

//Specifically this next line:
        <script src="/bower_components/requirejs/require.js"></script>

我在 html 文件中所做的任何更改都会在我运行 grunt 后立即恢复。我的所有 html 文件中都有这个问题。我有一个相当大的项目,我真的不知道要更改哪个配置文件来解决这个问题。

【问题讨论】:

  • 这和node.js有什么关系?
  • 没有线索。它被建议作为一个标签,我正在使用它,所以我只是认为它是合适的。不是吗?
  • 我没有看到上面的任何 node.js 代码(服务器端 javascript),你应该删除标签,这样它就不会出现在 node.js 标签队列中
  • 检查 /bower_components 文件夹是否由您的 grunt 脚本提供服务

标签: javascript npm gruntjs


【解决方案1】:

感谢您的帮助@topheman!

我找错地方了。 grunt 脚本中 /bower_components 的路径不正确。设置正确路径后,我的所有 html 脚本现在都没有此错误。

只是用错误的路径更改了这一行:

cwd: 'public/components',

用正确的路径进入这一行:

cwd: 'bower_components',

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-08-03
    • 1970-01-01
    • 2018-06-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多