久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

<legend id='XSkUu'><style id='XSkUu'><dir id='XSkUu'><q id='XSkUu'></q></dir></style></legend>
    • <bdo id='XSkUu'></bdo><ul id='XSkUu'></ul>

    1. <small id='XSkUu'></small><noframes id='XSkUu'>

    2. <tfoot id='XSkUu'></tfoot>
      <i id='XSkUu'><tr id='XSkUu'><dt id='XSkUu'><q id='XSkUu'><span id='XSkUu'><b id='XSkUu'><form id='XSkUu'><ins id='XSkUu'></ins><ul id='XSkUu'></ul><sub id='XSkUu'></sub></form><legend id='XSkUu'></legend><bdo id='XSkUu'><pre id='XSkUu'><center id='XSkUu'></center></pre></bdo></b><th id='XSkUu'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='XSkUu'><tfoot id='XSkUu'></tfoot><dl id='XSkUu'><fieldset id='XSkUu'></fieldset></dl></div>

        node.js TypeError: path must be absolute or specified root to

        node.js TypeError: path must be absolute or specify root to res.sendFile [failed to parse JSON](node.js TypeError: path must be absolute or specified root to res.sendFile [failed to parse JSON])
        <legend id='8C4Q2'><style id='8C4Q2'><dir id='8C4Q2'><q id='8C4Q2'></q></dir></style></legend>

        <i id='8C4Q2'><tr id='8C4Q2'><dt id='8C4Q2'><q id='8C4Q2'><span id='8C4Q2'><b id='8C4Q2'><form id='8C4Q2'><ins id='8C4Q2'></ins><ul id='8C4Q2'></ul><sub id='8C4Q2'></sub></form><legend id='8C4Q2'></legend><bdo id='8C4Q2'><pre id='8C4Q2'><center id='8C4Q2'></center></pre></bdo></b><th id='8C4Q2'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='8C4Q2'><tfoot id='8C4Q2'></tfoot><dl id='8C4Q2'><fieldset id='8C4Q2'></fieldset></dl></div>
            <tbody id='8C4Q2'></tbody>
          <tfoot id='8C4Q2'></tfoot>
        • <small id='8C4Q2'></small><noframes id='8C4Q2'>

                <bdo id='8C4Q2'></bdo><ul id='8C4Q2'></ul>

                  本文介紹了node.js TypeError: path must be absolute or specified root to res.sendFile [failed to parse JSON]的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  [添加]所以我的下一個問題是,當我嘗試添加新的依賴項時(npm install --save socket.io).JSON 文件也是有效的.我收到此錯誤:解析json失敗

                  [add] So my next problem is that when i try adding a new dependence (npm install --save socket.io). The JSON file is also valid. I get this error: Failed to parse json

                  npm ERR! Unexpected string
                  npm ERR! File: /Users/John/package.json
                  npm ERR! Failed to parse package.json data.
                  npm ERR! package.json must be actual JSON, not just JavaScript.
                  npm ERR! 
                  npm ERR! This is not a bug in npm.
                  npm ERR! Tell the package author to fix their package.json file. JSON.parse 
                  

                  所以我一直試圖弄清楚為什么這個錯誤一直在返回.所有文件(HTML、JSON、JS)都在我桌面上的同一個文件夾中.我正在使用 node.js 和 socket.io

                  So I've been trying to figure out why this error has been returning. All of the files (HTML,JSON,JS) are inside the same folder on my desktop. I'm using node.js and socket.io

                  這是我的 JS 文件:

                  This is my JS file:

                  var app = require('express')();
                  var http = require('http').Server(app);
                  
                  app.get('/', function(req, res){
                    res.sendFile('index.html');
                  });
                  
                  http.listen(3000,function(){
                      console.log('listening on : 3000');
                  });
                  

                  這是返回的內容:

                  MacBook-Pro:~ John$ node /Users/John/Desktop/Chatapp/index.js 
                  listening on : 3000
                  TypeError: path must be absolute or specify root to res.sendFile
                      at ServerResponse.sendFile (/Users/John/node_modules/express/lib/response.js:389:11)
                      at /Users/John/Desktop/Chatapp/index.js:5:7
                      at Layer.handle [as handle_request] (/Users/John/node_modules/express/lib/router/layer.js:76:5)
                      at next (/Users/John/node_modules/express/lib/router/route.js:100:13)
                      at Route.dispatch (/Users/John/node_modules/express/lib/router/route.js:81:3)
                      at Layer.handle [as handle_request] (/Users/John/node_modules/express/lib/router/layer.js:76:5)
                      at /Users/John/node_modules/express/lib/router/index.js:234:24
                      at Function.proto.process_params (/Users/John/node_modules/express/lib/router/index.js:312:12)
                      at /Users/John/node_modules/express/lib/router/index.js:228:12
                      at Function.match_layer (/Users/John/node_modules/express/lib/router/index.js:295:3)
                  TypeError: path must be absolute or specify root to res.sendFile
                      at ServerResponse.sendFile (/Users/John/node_modules/express/lib/response.js:389:11)
                      at /Users/John/Desktop/Chatapp/index.js:5:7
                      at Layer.handle [as handle_request] (/Users/John/node_modules/express/lib/router/layer.js:76:5)
                      at next (/Users/John/node_modules/express/lib/router/route.js:100:13)
                      at Route.dispatch (/Users/John/node_modules/express/lib/router/route.js:81:3)
                      at Layer.handle [as handle_request] (/Users/John/node_modules/express/lib/router/layer.js:76:5)
                      at /Users/John/node_modules/express/lib/router/index.js:234:24
                      at Function.proto.process_params (/Users/John/node_modules/express/lib/router/index.js:312:12)
                      at /Users/John/node_modules/express/lib/router/index.js:228:12
                      at Function.match_layer (/Users/John/node_modules/express/lib/router/index.js:295:3)
                  

                  推薦答案

                  錯誤很明顯,你需要指定一個絕對(而不是相對)路徑和/或在配置中設置 rootres.sendFile() 的對象.例子:

                  The error is pretty clear, you need to specify an absolute (instead of relative) path and/or set root in the config object for res.sendFile(). Examples:

                  // assuming index.html is in the same directory as this script
                  
                  res.sendFile(__dirname + '/index.html');
                  

                  或指定一個根(用作res.sendFile()的第一個參數的基本路徑:

                  or specify a root (which is used as the base path for the first argument to res.sendFile():

                  res.sendFile('index.html', { root: __dirname });
                  

                  當您傳遞用戶生成的文件路徑時,指定 root 路徑更有用,該路徑可能包含諸如 .. 之類的格式錯誤/惡意部分(例如 ../../../../../../etc/passwd).設置 root 路徑可防止此類惡意路徑被用于訪問該基本路徑之外的文件.

                  Specifying the root path is more useful when you're passing a user-generated file path which could potentially contain malformed/malicious parts like .. (e.g. ../../../../../../etc/passwd). Setting the root path prevents such malicious paths from being used to access files outside of that base path.

                  這篇關于node.js TypeError: path must be absolute or specified root to res.sendFile [failed to parse JSON]的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

                  【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

                  相關文檔推薦

                  Browser waits for ajax call to complete even after abort has been called (jQuery)(即使在調用 abort (jQuery) 之后,瀏覽器也會等待 ajax 調用完成)
                  JavaScript innerHTML is not working for IE?(JavaScript innerHTML 不適用于 IE?)
                  XMLHttpRequest cannot load, No #39;Access-Control-Allow-Origin#39; header is present on the requested resource(XMLHttpRequest 無法加載,請求的資源上不存在“Access-Control-Allow-Origin標頭) - IT屋-程序員軟件開發技術分
                  Is it possible for XHR HEAD requests to not follow redirects (301 302)(XHR HEAD 請求是否有可能不遵循重定向 (301 302))
                  XMLHttpRequest 206 Partial Content(XMLHttpRequest 206 部分內容)
                  Restrictions of XMLHttpRequest#39;s getResponseHeader()?(XMLHttpRequest 的 getResponseHeader() 的限制?)
                  • <tfoot id='iomRn'></tfoot><legend id='iomRn'><style id='iomRn'><dir id='iomRn'><q id='iomRn'></q></dir></style></legend>

                      <bdo id='iomRn'></bdo><ul id='iomRn'></ul>

                          <small id='iomRn'></small><noframes id='iomRn'>

                          <i id='iomRn'><tr id='iomRn'><dt id='iomRn'><q id='iomRn'><span id='iomRn'><b id='iomRn'><form id='iomRn'><ins id='iomRn'></ins><ul id='iomRn'></ul><sub id='iomRn'></sub></form><legend id='iomRn'></legend><bdo id='iomRn'><pre id='iomRn'><center id='iomRn'></center></pre></bdo></b><th id='iomRn'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='iomRn'><tfoot id='iomRn'></tfoot><dl id='iomRn'><fieldset id='iomRn'></fieldset></dl></div>

                              <tbody id='iomRn'></tbody>
                            主站蜘蛛池模板: 欧日韩不卡在线视频 | 精品在线观看一区二区 | 国产区精品 | 精品美女久久久 | 久草视频观看 | 精品欧美乱码久久久久久1区2区 | 国产精品一区二区三区在线 | se婷婷| 欧美精品乱码99久久影院 | 国产精品99精品久久免费 | 在线免费中文字幕 | 日韩免费中文字幕 | 一级做a爰片久久毛片 | 日韩一区二区三区四区五区 | 午夜欧美一区二区三区在线播放 | 欧美不卡一区二区三区 | 国产精品久久久久久久一区二区 | 激情a | 久久99精品国产99久久6男男 | 日本不卡一区二区三区在线观看 | 精品久久久久久国产 | 久久久久国产成人精品亚洲午夜 | 天天狠狠 | 欧美国产精品 | 亚洲精品久久久久久国产精华液 | 久久三区 | 国产精品视频www | 免费黄色大片 | 国产成人av一区二区三区 | 国产精品一区二 | 久久亚洲综合 | 国产精品福利网 | 国产一区二区在线观看视频 | 日本一区二区高清不卡 | 中文字幕国产一区 | 亚洲欧美一区二区三区国产精品 | 成人精品啪啪欧美成 | 热re99久久精品国产99热 | 中文字幕在线免费观看 | 亚洲一卡二卡 | 亚洲欧美综合精品久久成人 |