【问题标题】:how to use npm init <initializer> for my package? command not found error如何为我的包使用 npm init <initializer>?找不到命令错误
【发布时间】:2020-03-29 19:02:05
【问题描述】:

我在 npm 注册表https://www.npmjs.com/package/create-ts-starter 中有一个名为:create-ts-starter 的包。

我想用它作为我的项目启动器,使用命令npm init ts-starter,正如它在https://docs.npmjs.com/cli/init中解释的那样

但是当我运行它时,它只会显示错误:

npm init ts-starter
npx: installed 1 in 1.65s
command not found: create-ts-starter

这是 Github 仓库https://github.com/saostad/node-typescript-starter

我错过了什么?

【问题讨论】:

  • 我不确定,但也很想知道。文档确实提到了npm package named create-&lt;initializer&gt;,因此您的 repo/npm-package 名称可能需要以“create-”开头
  • 即使没有 repo 也可以工作,repo 只是我们可以提供的可选信息。我认为这应该与文档的and then have its main bin executed – presumably creating or updating package.json and running any other initialization-related operations.这部分有关。
  • 只是确定一下,你有 npm 6+ 吗?
  • 节点 v 13.3.0 & npm 6.13.1

标签: node.js npm npm-scripts npx


【解决方案1】:

我发现我错过了什么!它需要 package.json 文件中的“bin”字段和运行其余过程的脚本。现在,如果你运行npm init ts-starter,它会做我想做的所有事情:)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-03-22
    • 2016-11-30
    • 1970-01-01
    • 2018-04-02
    • 1970-01-01
    • 2021-01-05
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多