2017-10-12 102 views
0

嘗試運行以下代碼時出現以下錯誤。我的目標是刪除User和Item表中的所有項目。用戶和項目對應Dynamoose型號。Uncaught NetworkingError:無法讀取未定義的屬性「替換」錯誤

for循環運行正常。但是scan()。exec回調函數根本沒有運行,並且拋出了以下錯誤。

CircleCI真的很奇怪,這個問題不會發生。它只發生在我的本地計算機上。我嘗試刪除node_modules並運行npm install而沒有運氣。如果我刪除下面的代碼,它也可以正常工作。

任何想法?甚至在哪裏開始調試呢?

代碼:

var dbarray = [User, Item]; 
for (var i = 0; i < dbarray.length; i++) { 
    dbarray[i].scan().exec(function(err, items) { 
     if (err) { 
      throw err; 
     } 
     items.forEach(function(item, key) { 
      item.delete(); 
     }); 
    }); 
} 

錯誤:

General 
     1) "before each" hook 


    0 passing (10s) 
    1 failing 

    1) "before each" hook: 
    Uncaught NetworkingError: Cannot read property 'replace' of undefined 
     at findTargetPort (node_modules/zombie/lib/reroute.js:50:28) 
     at Socket.Net.Socket.connect (node_modules/zombie/lib/reroute.js:69:18) 
     at Agent.connect [as createConnection] (net.js:106:35) 
     at Agent.createSocket (_http_agent.js:217:26) 
     at Agent.addRequest (_http_agent.js:187:10) 
     at new ClientRequest (_http_client.js:272:16) 
     at Object.request (http.js:39:10) 
     at features.constructor.handleRequest (node_modules/aws-sdk/lib/http/node.js:42:23) 
     at executeSend (node_modules/aws-sdk/lib/event_listeners.js:304:29) 
     at Request.SEND (node_modules/aws-sdk/lib/event_listeners.js:318:9) 
     at Request.callListeners (node_modules/aws-sdk/lib/sequential_executor.js:101:18) 
     at Request.emit (node_modules/aws-sdk/lib/sequential_executor.js:77:10) 
     at Request.emit (node_modules/aws-sdk/lib/request.js:683:14) 
     at Request.transition (node_modules/aws-sdk/lib/request.js:22:10) 
     at AcceptorStateMachine.runTo (node_modules/aws-sdk/lib/state_machine.js:14:12) 
     at node_modules/aws-sdk/lib/state_machine.js:26:10 
     at Request.<anonymous> (node_modules/aws-sdk/lib/request.js:38:9) 
     at Request.<anonymous> (node_modules/aws-sdk/lib/request.js:685:12) 
     at Request.callListeners (node_modules/aws-sdk/lib/sequential_executor.js:115:18) 
     at callNextListener (node_modules/aws-sdk/lib/sequential_executor.js:95:12) 
     at node_modules/aws-sdk/lib/event_listeners.js:220:9 
     at finish (node_modules/aws-sdk/lib/config.js:315:7) 
     at node_modules/aws-sdk/lib/config.js:333:9 
     at Credentials.get (node_modules/aws-sdk/lib/credentials.js:126:7) 
     at getAsyncCredentials (node_modules/aws-sdk/lib/config.js:327:24) 
     at Config.getCredentials (node_modules/aws-sdk/lib/config.js:347:9) 
     at Request.SIGN (node_modules/aws-sdk/lib/event_listeners.js:192:22) 
     at Request.callListeners (node_modules/aws-sdk/lib/sequential_executor.js:101:18) 
     at Request.emit (node_modules/aws-sdk/lib/sequential_executor.js:77:10) 
     at Request.emit (node_modules/aws-sdk/lib/request.js:683:14) 
     at Request.transition (node_modules/aws-sdk/lib/request.js:22:10) 
     at AcceptorStateMachine.runTo (node_modules/aws-sdk/lib/state_machine.js:14:12) 
     at node_modules/aws-sdk/lib/state_machine.js:26:10 
     at Request.<anonymous> (node_modules/aws-sdk/lib/request.js:38:9) 
     at Request.<anonymous> (node_modules/aws-sdk/lib/request.js:685:12) 
     at Request.callListeners (node_modules/aws-sdk/lib/sequential_executor.js:115:18) 
     at Timeout.callNextListener [as _onTimeout] (node_modules/aws-sdk/lib/sequential_executor.js:95:12) 

回答

0

問題竟然是用Zombie.js。特別是Browser.localhost('localhost', port);。在每次訪問命令前刪除該行並傳入http://localhost:3000解決了該問題。

不知道爲什麼錯誤提到AWS及類似的東西。

相關問題