1

我正在尝试更新我的节点包/模块,很多人(很多来自 StackOverflow)推荐了“npm-check-updates”,所以我通过 npm 下载并运行它。它给了我这个错误,我不确定出了什么问题。系统设置中的 PATH 变量有什么问题吗?我似乎无法通过搜索谷歌找到任何有用的东西。谢谢! 在此处输入图像描述

4

1 回答 1

2

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

Github 源代码

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

这是运行此更新的示例。

~/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"
  }
}

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

于 2015-06-10T01:11:00.923 回答