Coder Social home page Coder Social logo

Comments (4)

rjgotten avatar rjgotten commented on August 27, 2024 2

Seems like NPM doesn't like when JS files are at top level in the bin field in package.json 😢

Not actually the problem. Top-level JS files are just fine.
The problem is that the package doesn't have an #!/usr/bin/env node moniker in the ./lib/bin.js file referred to by the bin field. Entries in the bin field require that moniker to instruct the tooling that they should use Node.JS to execute the files rather than try to run them directly. The NPM docs on the bin field literally state:

Please make sure that your file(s) referenced in bin starts with #!/usr/bin/env node, otherwise the scripts are started without the node executable!

Having the bin field top-level does introduce another problem though. A top-level bin field will generate command proxies in the node_modules/.bin folder that use the bare (!!) package name. I.e. the command you are creating won't be @typeoas/cli. It'll just be cli. Which has very poor discoverability.

Would recommend using

"bin" : { "typeoas-cli" : "./lib/bin.js" }

from typoas.

Embraser01 avatar Embraser01 commented on August 27, 2024

Hi,

Seems like NPM doesn't like when JS files are at top level in the bin field in package.json 😢
In the mean time, Yarn or pnpm are both working as expected.

Will mark this as a bug and try for a fix

from typoas.

Embraser01 avatar Embraser01 commented on August 27, 2024

Thank you for your help. I released a new version with the fix. From my testing, it should work now except for the following case:
When running npx inside an existing project, it fails with:

> Run npx @typoas/cli generate -i https://petstore3.swagger.io/api/v3/openapi.json -o test.ts
'typoas-cli' is not recognized as an internal or external command,
operable program or batch file.
> Error: Process completed with exit code 1.

I'm also adding some E2E tests to be sure.

from typoas.

Embraser01 avatar Embraser01 commented on August 27, 2024

Seems that it only fail in the typoas repo on Windows (maybe related to npm/cli#6276) , I'm gonna close this

from typoas.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.