当前位置: 首页 > 面试题库 >

npm出现“无法读取依赖项”错误

麹高义
2023-03-14
问题内容

我想启动一个Node应用程序,并使用教程创建了 package.json 文件。这是json文件:

{
    "name": "Dashboard",
    "version": "0.0.0",
    "description": "Client-A Dashboard",
    "dependencies": {
        "socket.io": "latest",
        "express": "latest",
        "jade": "latest"
    },
    "author": "tD"
}

在尝试运行JSON文件之前,我已经对其进行了验证,但是在运行npm install命令时仍然收到错误消息:

npm ERR! install Couldn't read dependencies
npm ERR! Error: ENOENT, open 'C:\projects\Client-A\Live\package.json'
npm ERR! If you need help, you may report this log at:
npm ERR!     <http://github.com/isaacs/npm/issues>
npm ERR! or email it to:
npm ERR!     <npm-@googlegroups.com>

npm ERR! System Windows_NT 6.1.7601
npm ERR! command "C:\\Program Files (x86)\\nodejs\\\\node.exe" "C:\\Program Files (x86)\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install"
npm ERR! cwd C:\projects\Client-A\Live\
npm ERR! node -v v0.8.22
npm ERR! npm -v 1.2.14
npm ERR! path C:\projects\Client-A\Live\package.json
npm ERR! code ENOENT
npm ERR! errno 34
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR!     C:\projects\Client-A\Live\npm-debug.log
npm ERR! not ok code 0

这是 npm-degub.log 文件

0 info it worked if it ends with ok
1 verbose cli [ 'C:\\Program Files (x86)\\nodejs\\\\node.exe',
1 verbose cli   'C:\\Program Files (x86)\\nodejs\\node_modules\\npm\\bin\\npm-cli.js',
1 verbose cli   'install' ]
2 info using npm@1.2.14
3 info using node@v0.8.22
4 verbose node symlink C:\Program Files (x86)\nodejs\\node.exe
5 verbose read json C:\projects\Client-A\Live\package.json
6 error install Couldn't read dependencies
7 error Error: ENOENT, open 'C:\projects\Client-A\Live\package.json'
8 error If you need help, you may report this log at:
8 error     <http://github.com/isaacs/npm/issues>
8 error or email it to:
8 error     <npm-@googlegroups.com>
9 error System Windows_NT 6.1.7601
10 error command "C:\\Program Files (x86)\\nodejs\\\\node.exe" "C:\\Program Files (x86)\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install"
11 error cwd C:\projects\Client-A\Live\scoreboard
12 error node -v v0.8.22
13 error npm -v 1.2.14
14 error path C:\projects\Client-A\Live\package.json
15 error code ENOENT
16 error errno 34
17 verbose exit [ 34, true ]

问题答案:

尝试添加以下内容:

"private": true,

它为我工作。

编辑 (对于问为什么的人):

该公报的文件规定如下:

如果"private": true在package.json中设置,则npm将拒绝发布它。这是防止意外发布私有存储库的方法。如果要确保仅将给定的程序包发布到特定的注册表(例如,内部注册表),请使用publishConfig下面描述的哈希值registry在发布时覆盖config参数。

您收到的错误消息可能与某种程度上违反了该“规则”有关(我以前是)。

  • 您正在将未发布的程序包(例如您自己的应用程序)标记为 "private": false
  • 否则您就根本不考虑任何价值。


 类似资料:
  • 我有这种情况。我正在用Spring Boot开发一个REST服务,我有一个dependency jar,这是另一个Spring Boot项目,我使用以下方法将其作为一个依赖项包括在内: https://docs.spring.io/spring-boot/docs/2.1.4.release/maven-plugin/examples/repackage-classifier.html 一切都编译

  • 最近,在Jenkins中运行的Maven构建作业失败了,但有以下例外,它们不能从Maven Central中提取依赖项,因此应该使用HTTPS。我不知道如何将请求从HTTP更改为HTTPS。在这件事上有人能指导我吗? [错误]无法解析的生成扩展: 插件或其依赖项之一无法解析: 未能收集: 未能读取: 无法将项目: 无法将项目->[帮助2] 正在等待Jenkins完成收集 Plugin或其依赖项之一

  • 我对Android的Gradle构建有问题。我尝试了很多方法来解决这个问题,但没有什么不起作用。我需要帮助。 Gradle版本:4.4 Gradle插件:3.0.1 错误:无法解析app@serverDebug /compileClasspath的依赖关系:无法解析项目:vksdk_library。 错误:无法解析“”的依存关系:app@mockDebugAndroidTest/compileCl

  • 问题内容: 最近,在 Jenkins 中运行的 Maven 构建作业失败,但出现以下异常,原因是它们无法从 Maven Central 提取依赖项,应使用 HTTPS 。我不确定如何将请求从 HTTP 更改为 HTTPS 。有人可以指导我吗? __ [错误] 无法解析的构建扩展: 插件或其依赖项之一无法解析: 无法收集以下项的依赖项: 无法读取以下项的工件描述符: 无法从/到中央传输工件(http

  • 我在pom.xml中添加了私有nexus存储库网址,以便从内部nexus存储库安装一些依赖项。 但是eclipse仍然在pom.xml文件中显示“丢失工件错误”消息 下面是我运行mvn安装命令时的命令行错误消息 [错误]无法对项目diffapi执行目标:无法解析项目com的依赖项。my:diffapi:jar:0.0.1-SNAPSHOT:无法解析以下工件:com。aaa。bbb。波伊。jar:p

  • 问题内容: 当我输入command go build时,我有一个项目具有来自bitbucket上私人存储库的多个依赖项。我得到这个错误 无法识别的导入路径“ bitbucket.xxx.xx / xx / x” x509:证书由未知授权机构签名 我已经尝试了几种方法,例如添加令牌 git config –global http.extraheader令牌 配置为ssh git config –gl