我正在尝试获取在dependencies文件中设置的当前package.json和devDependencies版本,以便当为新用户运行MakeFile时,它会安装其中列出的版本,而不仅仅是最新版本。因此,对于下面的示例,我们不只是说npm install @applitools/eyes-testcafe,而是从package.json获取1.16.1版本,并将其插入到MakeFile中,比如${eyes_version}或类似的东西。
知道怎么做吗?谢谢!
package.json
"devDependencies": {
"@applitools/eyes-testcafe": "^1.16.1",
"testcafe": "^1.18.6",
"testcafe-reporter-xunit": "*"
}MakeFile
install-testcafe: npm ffmpeg applitools testcafe
# Installs all dependencies necessary for testcafe and node to run.
npm:
npm install
# Installs the ffmpeg video recorder. This is recursive as sometimes it doesn't install automatically.
ffmpeg:
npm install @ffmpeg-installer/ffmpeg
# Installs the applitools dependency. This is recursive as sometimes it doesn't install automatically.
applitools:
npm install @applitools/eyes-testcafe
# Installs TestCafe globally. This is recursive as sometimes it doesn't install automatically.
testcafe:
sudo npm install -g testcafe发布于 2022-06-09 19:55:35
既然你在使用jq,
jq '.devDependencies["@applitools/eyes-testcafe"]' package.json有用吗?
我怀疑在NPM周围使用Make包装器的有效性/有用性。您正在将构建工具包装在构建工具中。为什么?我猜是为了让来自C/Make生态系统的开发人员更加熟悉它。但是,像这样将Make和NPM混合在一起会使Node/NPM开发人员感到困惑,NPM脚本可以像Make一样运行CLI命令。
npm i真的比make npm复杂吗?在自述文件中,这些信息似乎更好,应该让开发人员了解如何使用NPM (例如,您可以在NPM脚本中运行CLI命令)。在这里添加Make脚本并没有增加任何价值,但是YMMV,也许这在您的组织中特别有用。
此外,在运行sudo时也不要使用npm。
https://stackoverflow.com/questions/72564278
复制相似问题