欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

FAQ:NodeJS安装报错npm WARN saveError ENOENT: no such file or directory, open 'G:\Node\package.json'

程序员文章站 2022-05-30 09:14:31
...
在安装npm安装包的时候报错如下:
npm WARN saveError ENOENT: no such file or directory, open 'G:\Node\package.json'
npm WARN enoent ENOENT: no such file or directory, open 'G:\Node\package.json'
npm WARN Node No description
npm WARN Node No repository field.
npm WARN Node No README data
npm WARN Node No license field.

原因:项目目录中没有package.json


解决:

使用 npm init -f 命令来生成一个package.json


生成package.json在执行npm install xxx

npm WARN [email protected] No description
npm WARN [email protected] No repository field.
npm WARN [email protected] No repository field or no license field

显示缺少description描述和repository字段,还有private字段

根据模板package.json,添加description中的值以及repository字段

{
  "name": "WeiXinNode",
  "version": "1.0.0",
  "description": "这里是------description",
  "main": "index.js",
  "dependencies": {
    "koa": "^2.1.0",
    "sha1": "^1.1.1"
  },
  "devDependencies": {},
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "repository": { 这里是------repository字段
    "type": "",
    "url": ""
  },
  "private": true   这里是------private字段
}

再执行npm install xxx,就可以了
相关标签: node