报错情况:
在执行npm install xxx时,出现如下:
npm WARN saveError ENOENT: no such file or directory, open '/nodetest1/package.json' npm WARN enoent ENOENT: no such file or directory, open '/nodetest1/package.json'
原因:项目目录中没有package.json
解决:
使用 npm init -f 命令来生成一个package.json
生成package.json在执行npm install xxx
npm WARN nodetest1@1.0.0 No description npm WARN nodetest1@1.0.0 No repository field. npm WARN file-explorer@0.0.1 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
OK