node.js - 为 npm 使用不同于 "package.json"的文件名

标签 node.js npm command-line-interface

有没有办法从命令行告诉 npm 使用与“package.json”不同的文件?

编辑:

感谢您的回答。我已经检查了文档并希望有一种解决方法或一种未记录的方法来实现这一点。那我再想想别的办法。

最佳答案

仅使用客户端空间工具,这似乎很简单,但您做不到。 npm doc 对此持肯定态度:

A package is: 
    a) a folder containing a program described by a package.json file
    b) a gzipped tarball containing (a) 
    c) a url thatresolves to (b) 
    d) a <name>@<version> that is published on theregistry with (c) 
    e) a <name>@<tag> that points to (d) 
    f) a <name>that has a "latest" tag satisfying (e) 
    g) a git url that, when cloned,results in (a).
[...]

You need to have a package.json file in the root of your project to do much of anything with npm. That is basically the whole interface.

source : npm doc

如您所见,他们非常清楚 package.json 是任何工作所必需的。

您必须深入研究代码,才能获得不可重用的结果。如果这是您想要的,请在您的问题中明确说明,以便其他人理解为什么有必要这样做。

关于node.js - 为 npm 使用不同于 "package.json"的文件名,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25991082/

相关文章:

node.js - nodejs 树莓派 串口数据不正确

node.js - 表示 cookieSession 和 Mongoose : how can I make request. session.user 是 Mongoose 模型?

javascript - 无法从 Node js模块导出变量

node.js - 我如何始终在传播先前错误代码的 bash 中运行 "clean up"命令?

npm install issue : 27 vulnerabilities (16 moderate, 9 high, 2 critical) 要解决所有问题,请运行:npm audit fix --force

php - $_SERVER ['argv' ] HTTP GET 和 CLI 问题

node.js - create-react-app 命令中止安装为什么?

node.js - npm 错误!远程 : Invalid username or password

java - 以编程方式将 Artifact 部署到 Nexus 的快速方法(在 Java 中)

cordova - 如何使用 Phonegap CLI 创建/构建本地应用程序