简体   繁体   English

oclif 无法识别创建的命令

[英]oclif doesn't recognise created commands

I'm trying to build a CLI using oclif and it doesn't seem to work for anything I tried.我正在尝试使用 oclif 构建 CLI,但它似乎对我尝试的任何事情都不起作用。 I see a lot of people making it work for them so can maybe someone point me to my issue!我看到很多人让它为他们工作所以也许有人可以指出我的问题!

My steps:我的步骤:

 1. mkdir test && cd test
 2. npm init -f
 3. npm i oclif
 4. npx oclif generate my_test //this generates a new cli
 5. cd my_test
 6. npx oclif generate command bob
 7. npm link
 8. npx my_test bob

I always get我总是得到

 ›   Error: command bob not found

Same if I do ./bin/run bob如果我这样做也一样./bin/run bob

However, if I run the test for the bob command, the test passes.但是,如果我为 bob 命令运行测试,则测试通过。

Thank you in advance.先感谢您。

Sorry for being late replying... Intel's answer is almost correct - and until version 6 of npm it actually was.抱歉回复晚了......英特尔的回答几乎是正确的 - 直到 npm 的第 6 版它实际上是正确的。 Correct is:正确的是:

npm run build

Whereas oclif generate command just creates the Typescript file for the command and its test class under src/, above will create its Javascript file into dist/.oclif generate command只是在 src/ 下为该命令创建 Typescript 文件及其测试 class,上面将在 dist/ 中创建其 Javascript 文件。 npm link does probably nothing to your project at all - just creates a symlink pointing to it. npm link可能对您的项目根本没有任何作用——只是创建一个指向它的符号链接。 npm test makes use of ts-node to directly execute Typescript. npm test利用ts-node直接执行Typescript。

run npm build , then you have it!运行npm build ,然后你就拥有了!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM