【发布时间】:2020-12-16 23:49:22
【问题描述】:
我对 node.js、npm 和 JavaScript 非常陌生,但为了尝试使用 Istanbul 工具进行代码覆盖,因此安装了 nyc 和 npm i nyc 指的是 https://www.npmjs.com/package/nyc,其输出类似于
C:\Users\user>npm i nyc
npm WARN saveError ENOENT: no such file or directory, open 'C:\Users\user\package.json'
npm WARN enoent ENOENT: no such file or directory, open 'C:\Users\user\package.json'
npm WARN user No description
npm WARN user No repository field.
npm WARN user No README data
npm WARN user No license field.
+ nyc@15.1.0
updated 1 package in 1.334s
9 packages are looking for funding
run `npm fund` for details
但是当我点击nyc o 命令提示符时,它说 - nyc is not Recognized as internal or external command。
根据文档,我添加了 dev 依赖项,但看到了相同的错误。
C:\Users\user>npm i -D nyc
npm WARN saveError ENOENT: no such file or directory, open 'C:\Users\user\package.json'
npm notice created a lockfile as package-lock.json. You should commit this file.
npm WARN enoent ENOENT: no such file or directory, open 'C:\Users\user\package.json'
npm WARN user No description
npm WARN user No repository field.
npm WARN user No README data
npm WARN user No license field.
+ nyc@15.1.0
added 142 packages from 99 contributors in 48.325s
9 packages are looking for funding
run `npm fund` for details
请指导我这里出了什么问题。
【问题讨论】:
-
`C:\Users\user` 有
package.json文件吗? -
不,它不存在。我无法找到从哪里获取它以及内容应该是什么