lite-server不在/ js文件夹中提供.js文件 - 浏览器不会请求/ js文件

时间:2017-03-11 18:11:35

标签: javascript node.js npm lite-server

我正在使用lite-server

运行npm run lite

我的jQuery文件正常加载,我的css也在css文件夹中,但是浏览器甚至没有发出main.js文件的GET请求。

main.js文件在/ js文件夹中作为style.css在/ css文件夹中

我错过了什么吗?

这是我的HTML

<!DOCTYPE html>
<html>
    <head>
        <script type="text/javascript" src="node_modules/jquery/dist/jquery.js"></script>
        <script type="text/javascript" scr="js/main.js"></script>
        <link rel="stylesheet" type="text/css" href="css/style.css">
    </head>
    <body>
        test
    </body>
</html>

编辑: - &gt;刚刚意识到浏览器没有对此文件发出GET请求。如果我直接向js文件发出请求,服务器也会返回它。

index.html request main.js request

npm run lite正在运行:

$ npm run lite

> sdfa@1.0.0 lite C:\temp\nodeIntro
> lite-server

Did not detect a `bs-config.json` or `bs-config.js` override file. Using lite-server defaults...
** browser-sync config **
{ injectChanges: false,
  files: [ './**/*.{html,htm,css,js}' ],
  watchOptions: { ignored: 'node_modules' },
  server: { baseDir: './', middleware: [ [Function], [Function] ] } }
[BS] Access URLs:
 ------------------------------------
       Local: http://localhost:3000
    External: http://192.168.1.4:3000
 ------------------------------------
          UI: http://localhost:3001
 UI External: http://192.168.1.4:3001
 ------------------------------------
[BS] Serving files from: ./
[BS] Watching files...
17.03.11 12:52:27 304 GET /index.html
17.03.11 12:52:27 304 GET /node_modules/jquery/dist/jquery.min.js
17.03.11 12:52:27 304 GET /node_modules/jquery/dist/jquery.js
17.03.11 12:52:27 304 GET /css/style.css

1 个答案:

答案 0 :(得分:1)

您错误地输入了 src scr

错误

正确

<script type="text/javascript" src="js/main.js"></script>