使用npm-check-updates进行更新时,找不到Package.json错误

时间:2021-04-22 17:40:41

I'm trying to update my node packages/modules and a lot of people (many from *) recommended 'npm-check-updates' so I downloaded via npm and ran it. It gave me this error and I'm not sure what's wrong. Is something wrong with my PATH variable in system settings or something? I can't seem to find anything useful with searching Google. Thank you! 使用npm-check-updates进行更新时,找不到Package.json错误

我正在尝试更新我的节点包/模块,很多人(很多来自*)建议'npm-check-updates',所以我通过npm下载并运行它。它给了我这个错误,我不确定是什么问题。我的PATH变量在系统设置中出了什么问题?我似乎找不到任何有用的搜索谷歌。谢谢!

1 个解决方案

#1


2  

npm-check-updates node module requires package.json file to check for the versions that your application is currently using. From the code, it looks for particularly package.json in the current directory to read application dependencies and throws an error if the file is not found.

npm-check-updates节点模块需要package.json文件来检查应用程序当前使用的版本。从代码中,它在当前目录中查找特别是package.json来读取应用程序依赖项,如果找不到该文件则抛出错误。

Github Source Code

Github源代码

If package.json file exists, the module checks which packages can be updated to a higher version and are outdated. Once you review the suggestions and manually verifiy, you would want to run the module with -u option, which will automatically upgrade the package.json file with the newer version numbers of the dependencies. Once this is done, you can run npm install to download the latest versions.

如果package.json文件存在,则模块会检查哪些包可以更新到更高版本并且过时。一旦您查看建议并手动验证,您可能希望使用-u选项运行该模块,该选项将使用较新的依赖项版本号自动升级package.json文件。完成后,您可以运行npm install来下载最新版本。

Here is an example of running this update.

以下是运行此更新的示例。

~/Downloads/hackingedu/project 512-> ./node_modules/npm-check-updates/bin/npm-check-updates 

"babelify" can be updated from 6.0.2 to 6.1.2 (Installed: 6.0.2, Latest: 6.1.2)
"browserify" can be updated from 9.0.8 to 10.2.4 (Installed: 9.0.8, Latest: 10.2.4)
"canvas" can be updated from 1.2.2 to 1.2.3 (Installed: none, Latest: 1.2.3)
"express" can be updated from 4.12.3 to 4.12.4 (Installed: 4.12.3, Latest: 4.12.4)

Run with '-u' to upgrade your package.json
~/Downloads/hackingedu/project 513-> mv package.json package.json.old
~/Downloads/hackingedu/project 514-> ./node_modules/npm-check-updates/bin/npm-check-updates 
package.json not found
~/Downloads/hackingedu/project 515-> mv package.json.old package.json
~/Downloads/hackingedu/project 516-> cat package.json 
{
  "name": "workshop",
  "version": "0.0.1",
  "description": "",
  "dependencies": {
    "babelify": "6.0.2",
    "browserify": "9.0.8",
    "canvas": "1.2.2",
    "express": "4.12.3",
    "gameboy": "0.2.0",
    "socket.io": "1.3.5"
  }
}
~/Downloads/hackingedu/project 517-> ./node_modules/npm-check-updates/bin/npm-check-updates -u

"babelify" can be updated from 6.0.2 to 6.1.2 (Installed: 6.0.2, Latest: 6.1.2)
"browserify" can be updated from 9.0.8 to 10.2.4 (Installed: 9.0.8, Latest: 10.2.4)
"canvas" can be updated from 1.2.2 to 1.2.3 (Installed: none, Latest: 1.2.3)
"express" can be updated from 4.12.3 to 4.12.4 (Installed: 4.12.3, Latest: 4.12.4)

package.json upgraded
~/Downloads/hackingedu/project 518-> cat package.json 
{
  "name": "workshop",
  "version": "0.0.1",
  "description": "",
  "dependencies": {
    "babelify": "6.1.2",
    "browserify": "10.2.4",
    "canvas": "1.2.3",
    "express": "4.12.4",
    "gameboy": "0.2.0",
    "socket.io": "1.3.5"
  }
}

It is recommended to use semantic versioning in your package.json file, you can learn more on package.json best practices.

建议在package.json文件中使用语义版本控制,您可以了解有关package.json最佳实践的更多信息。

#1


2  

npm-check-updates node module requires package.json file to check for the versions that your application is currently using. From the code, it looks for particularly package.json in the current directory to read application dependencies and throws an error if the file is not found.

npm-check-updates节点模块需要package.json文件来检查应用程序当前使用的版本。从代码中,它在当前目录中查找特别是package.json来读取应用程序依赖项,如果找不到该文件则抛出错误。

Github Source Code

Github源代码

If package.json file exists, the module checks which packages can be updated to a higher version and are outdated. Once you review the suggestions and manually verifiy, you would want to run the module with -u option, which will automatically upgrade the package.json file with the newer version numbers of the dependencies. Once this is done, you can run npm install to download the latest versions.

如果package.json文件存在,则模块会检查哪些包可以更新到更高版本并且过时。一旦您查看建议并手动验证,您可能希望使用-u选项运行该模块,该选项将使用较新的依赖项版本号自动升级package.json文件。完成后,您可以运行npm install来下载最新版本。

Here is an example of running this update.

以下是运行此更新的示例。

~/Downloads/hackingedu/project 512-> ./node_modules/npm-check-updates/bin/npm-check-updates 

"babelify" can be updated from 6.0.2 to 6.1.2 (Installed: 6.0.2, Latest: 6.1.2)
"browserify" can be updated from 9.0.8 to 10.2.4 (Installed: 9.0.8, Latest: 10.2.4)
"canvas" can be updated from 1.2.2 to 1.2.3 (Installed: none, Latest: 1.2.3)
"express" can be updated from 4.12.3 to 4.12.4 (Installed: 4.12.3, Latest: 4.12.4)

Run with '-u' to upgrade your package.json
~/Downloads/hackingedu/project 513-> mv package.json package.json.old
~/Downloads/hackingedu/project 514-> ./node_modules/npm-check-updates/bin/npm-check-updates 
package.json not found
~/Downloads/hackingedu/project 515-> mv package.json.old package.json
~/Downloads/hackingedu/project 516-> cat package.json 
{
  "name": "workshop",
  "version": "0.0.1",
  "description": "",
  "dependencies": {
    "babelify": "6.0.2",
    "browserify": "9.0.8",
    "canvas": "1.2.2",
    "express": "4.12.3",
    "gameboy": "0.2.0",
    "socket.io": "1.3.5"
  }
}
~/Downloads/hackingedu/project 517-> ./node_modules/npm-check-updates/bin/npm-check-updates -u

"babelify" can be updated from 6.0.2 to 6.1.2 (Installed: 6.0.2, Latest: 6.1.2)
"browserify" can be updated from 9.0.8 to 10.2.4 (Installed: 9.0.8, Latest: 10.2.4)
"canvas" can be updated from 1.2.2 to 1.2.3 (Installed: none, Latest: 1.2.3)
"express" can be updated from 4.12.3 to 4.12.4 (Installed: 4.12.3, Latest: 4.12.4)

package.json upgraded
~/Downloads/hackingedu/project 518-> cat package.json 
{
  "name": "workshop",
  "version": "0.0.1",
  "description": "",
  "dependencies": {
    "babelify": "6.1.2",
    "browserify": "10.2.4",
    "canvas": "1.2.3",
    "express": "4.12.4",
    "gameboy": "0.2.0",
    "socket.io": "1.3.5"
  }
}

It is recommended to use semantic versioning in your package.json file, you can learn more on package.json best practices.

建议在package.json文件中使用语义版本控制,您可以了解有关package.json最佳实践的更多信息。