【问题标题】:Jest js Install - getting error -- npm ERR! Class constructor cannot be invoked without 'new'Jest js 安装 - 出现错误 - npm ERR!没有'new'就不能调用类构造函数
【发布时间】:2018-12-13 22:43:14
【问题描述】:

我正在尝试使用以下命令安装 jest

npm i jest --save-dev

我收到以下错误

npm ERR! Windows_NT 6.1.7601
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\
node_modules\\npm\\bin\\npm-cli.js" "i" "jest" "--save-dev"
npm ERR! node v8.11.3
npm ERR! npm  v5.6.0

npm ERR! Class constructor  cannot be invoked without 'new'
npm ERR!
npm ERR! If you need help, you may report this error at:
npm ERR!     <https://github.com/npm/npm/issues>

npm ERR! Please include the following file with any support request:
npm ERR!     C:\Windows\system32\npm-debug.log

知道可能是什么问题吗?

【问题讨论】:

  • 节点版本是多少?
  • 节点 v8.11.3 npm v5.6.0
  • 我刚刚运行了安装命令,它工作了。 + jest@23.6.0 added 557 packages from 341 contributors and audited 17606 packages in 148.343s found 0 vulnerabilities
  • 你能发布你的 package.json 吗?
  • { "name": "unit-testing-functions", "version": "1.0.0", "description": "", "main": "index.js", "scripts ": { "test": "echo \"Error: no test specified\" && exit 1" }, "keywords": [], "author": "", "license": "ISC" }

标签: node.js npm jestjs


【解决方案1】:

使用

更改 .bablerc 中的预设
"presets": ["es2015", "stage-2", "react"]

另外,尝试删除 package-lock.json 和 node_modules,然后 npm i 再试一次

【讨论】:

  • 我在哪里可以找到这个项目的 .bablerc 文件
  • 没有的需要自己添加
  • 谢谢。实际问题出在我的 org 防火墙上。不允许我安装任何节点。
猜你喜欢
  • 1970-01-01
  • 2017-09-29
  • 2018-09-19
  • 1970-01-01
  • 2020-08-11
  • 1970-01-01
  • 1970-01-01
  • 2018-11-12
相关资源
最近更新 更多