2015-06-05 21 views
3

以下錯誤意味着什麼?我應該如何解決?TypeError:可能無法在嚴格模式函數或調用參數對象上訪問'caller','callee'和'arguments'屬性

$ npm test 

> [email protected] test /Users/mishamoroshko/location-autosuggest 
> mocha test --compilers js:babel/register 



    compareKeys() 
    should return -1 
     1) when first key is different 


    0 passing (301ms) 
    1 failing 

    1) compareKeys() should return -1 when first key is different: 
    TypeError: 'caller', 'callee', and 'arguments' properties may not be accessed on strict mode functions or the arguments objects for calls to them 
     at Context.<anonymous> (compare-keys/compare-keys.test.js:3:16) 

以下是有關部分:

比較密鑰/比較-keys.test.js

1. 'use strict'; 
2. 
3. import { expect } from 'chai'; 

的package.json

"scripts": { 
    "test": "mocha test --compilers js:babel/register" 
} 

。 babelrc

{ 
    "stage": 0 
} 

mocha.opts

我沒有一個。

版本

  • 巴貝爾:5.5.1
  • 摩卡:2.2.5
  • 柴:3.0.0
+0

相似的問題stackoverflow.com/a/29130322/1909531這裏我發現解決方案排除:/ node_modules/ –

+0

我對同一問題的回答https://stackoverflow.com/a/44666529/1114926 – Green

回答

0

ES5以來,在嚴格模式下,不能使用諸如callee等參數的一些性質 參見例如關於callee page的MDN上的免責聲明:

The 5th edition of ECMAScript (ES5) forbids use of arguments.callee() in strict mode. Avoid using arguments.callee() by either giving function expressions a name or use a function declaration where a function must call itself.

chai可能會使用這些屬性之一。

+0

是不是巴貝爾忽略' node_modules'默認?見:http://babeljs.io/docs/usage/require/#usage –

+0

我想這不是巴貝爾,但包含頂級'使用嚴格'的包本身和使用被拒絕的屬性的庫 – krampstudio

-2

我更新了babel到5.5.3,並解決了問題。

+0

我有這個相同的問題,但似乎沒有解決它對我來說。我有[email protected] [email protected]有什麼想法? –

相關問題