Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/462.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/node.js/35.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript TypeError:超级表达式必须为null或函数_Javascript_Node.js_Vue.js - Fatal编程技术网

Javascript TypeError:超级表达式必须为null或函数

Javascript TypeError:超级表达式必须为null或函数,javascript,node.js,vue.js,Javascript,Node.js,Vue.js,我对vue js中的单元测试非常陌生。我只是浏览了这个网站来学习单元测试。当我在mocha网页上练习示例时,我遇到了这个错误 WEBPACK Failed to compile with 1 error(s) Error in ./src/Counter.vue TypeError: Super expression must either be null or a function at /opt/htdocs/guru/unitTest_prct/node_modules/prettier

我对vue js中的单元测试非常陌生。我只是浏览了这个网站来学习单元测试。当我在mocha网页上练习示例时,我遇到了这个错误

WEBPACK  Failed to compile with 1 error(s)
Error in ./src/Counter.vue
TypeError: Super expression must either be null or a function
at /opt/htdocs/guru/unitTest_prct/node_modules/prettier/index.js:32893:5
at /opt/htdocs/guru/unitTest_prct/node_modules/prettier/index.js:32913:4
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! mdbvue@4.2.0 test: `mocha-webpack --webpack-config  webpack.config.js --require test/setup.js test/**/*.spec.js`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the mdbvue@4.2.0 test script.
npm ERR! This is probably not a problem with npm. There is likely     additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2018-09-06T10_28_47_073Z-debug.log
谁能告诉我如何解决这个错误。这是我的Counter.vue文件

<template>
  <div>
   <div>
     {{ count }}
     <button @click="increment">Increment</button>
   </div>
  </div>
</template>

<script>
export default {
    data () {
       return {
         count: 0
       }
    },
   methods: {
      increment () {
        this.count++;
      }
    }
};
</script>

这是与prettier版本1.14.1相关的问题,prettier是您的场景中使用的NPM包

事实上,从他们的观点来看,这一问题已被报道。目前有一个可能的解决办法:基本上是注释掉prettier/index.js的第32893行


在您的环境中,您可以在此处找到文件:/opt/htdocs/guru/unitTest\u prct/node\u modules/

这是与prettier版本1.14.1相关的问题,prettier是您场景中使用的NPM包

事实上,从他们的观点来看,这一问题已被报道。目前有一个可能的解决办法:基本上是注释掉prettier/index.js的第32893行

在您的环境中,您可以在此处找到文件:/opt/htdocs/guru/unitTest\u prct/node\u modules/

我已经查看了链接

我在测试脚本中有-require test/setup.js。下面是它的样子:

require('jsdom-global')();
window.Date = Date;
它解决了这个问题。试试看

我已经看过linked了

我在测试脚本中有-require test/setup.js。下面是它的样子:

require('jsdom-global')();
window.Date = Date;

它解决了这个问题。试试看

你可以发布你的Counter.vue文件吗?@yuriy636我已经更新了我的Counter.vue文件我们可以查看你的导入吗?@P3trur0这里我添加了我的Counter.spec.js文件你可以发布你的Counter.vue文件吗?@yuriy636我已经更新了我的Counter.vue文件我们可以查看你的导入吗?@P3trur0这里我添加了我的Counter.spec.js文件好!当然,请注意,这是一个不适合生产的解决方法。但我怀疑版本是否是我的问题,这意味着现在我已经将版本更新为1.14.1到1.14.2,但我仍然面临这个问题。为什么?GitHub上的错误看起来仍然存在;1.14.1是其引入的版本。我想这将在将来得到修复。我正在使用sed-I.bak'32893s/^../\/\/'node\u modules/prettier/index.js在我们进行新设置时注释掉这一行,但希望您能指导我们如何降级有问题的prettify版本?“你的意思是降低vue测试utils的等级吗?@TheMath魔术师是的,我是这个意思。”。您应该使用Prentifier 1.14.1版本检查哪个版本的vue test utils取决于NPM模块,并相应地进行更换。然而,由于这个bug应该在将来的版本中修复,所以在考虑降级之前,我会在解决方案中停留一段时间。很好!当然,请注意,这是一个不适合生产的解决方法。但我怀疑版本是否是我的问题,这意味着现在我已经将版本更新为1.14.1到1.14.2,但我仍然面临这个问题。为什么?GitHub上的错误看起来仍然存在;1.14.1是其引入的版本。我想这将在将来得到修复。我正在使用sed-I.bak'32893s/^../\/\/'node\u modules/prettier/index.js在我们进行新设置时注释掉这一行,但希望您能指导我们如何降级有问题的prettify版本?“你的意思是降低vue测试utils的等级吗?@TheMath魔术师是的,我是这个意思。”。您应该使用Prentifier 1.14.1版本检查哪个版本的vue test utils取决于NPM模块,并相应地进行更换。然而,IMHO,因为这个bug应该在未来的版本中修复,所以在考虑降级之前,我会在解决方案中停留一段时间。