Use different filename for npm than “package.json”

点点圈 提交于 2019-12-05 03:31:34

Using only client-space tools, it seems pretty straightforward you can't. npm doc is positive about this :

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

As you can see, they make it really clear a package.json is required for anything to work.

You'd have to dig into the code, for a result which would not be reusable. If it's what you want, please make it clear in your question for others to understand why it's necessary.

Nope. As described in the npm-install docs, this is the only syntaxes you can use :

npm install (with no args in a package dir)
npm install <tarball file>
npm install <tarball url>
npm install <folder>
npm install [@<scope>/]<name> [--save|--save-dev|--save-optional] [--save-exact]
npm install [@<scope>/]<name>@<tag>
npm install [@<scope>/]<name>@<version>
npm install [@<scope>/]<name>@<version range>
npm i (with any of the previous argument usage)

With no args, the command will install a folder containing a program described by a package.json file.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!