Git Product home page Git Product logo

create-yo's Introduction

create-yo

Use any Yeoman generator with "npm init"

As of npm v6.1.0, you can use a custom package with npm init to scaffold a project.

Table of Contents

Install

You could install this, but you shouldn't have to. Use npm to install globally if you wish.

Requirements

  • Node.js v10.0.0+
  • npm v6.1.0+

Usage

$ npm init yo <some-generator>[:subgenerator]

All Yeoman generator packages start with generator-; this prefix is optional unless you are using a scoped package. In other words, npm init yo license will work just as well as npm init yo generator-license, but to use generator @butts/generator-butts, you must specify the complete package name with npm init yo @butts/generator-butts.

See a list of generators here.

Notes

This package does little other than monkey with arguments and invoke npx programmatically.

Contribution

Please use Conventional Commit conventions. Commit messages are checked via Git hook using commitlint.

Maintainers

@boneskull

License

Copyright © 2019 Christopher Hiller. Licensed Apache-2.0

create-yo's People

Contributors

boneskull avatar dependabot[bot] avatar vladimyr avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

create-yo's Issues

command not found: yo

Hello,
Thanks a lot for the great effort with this. From the code it looks like you really tried hard to cover many cases.

Unfortunately when I run this though, I get an error:

npm init yo express
npx: installed 128 in 6.422s
npx: installed 412 in 13.06s
npx: command not found: yo

I'm running Node v11.3.0 and npm v6.5.0 if that helps, but I don't expect anything really changed in either to block this awesome script. I don't know.

Any thoughts?

Thanks again.

Error when trying your generator example

This is a very cool idea!

I tried it with the example from your blog post:

npm init yo generator

This was the output:

$ npm init yo generator
npx: Installierte 15 in 2.075s
Command failed: C:\"Program Files"\nodejs\node.exe "C:\Users\dmorgenstern\AppData\Roaming\npm\npm" config get cache --parseable
C:\Users\dmorgenstern\AppData\Roaming\npm\npm:2
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
          ^^^^^^^

SyntaxError: missing ) after argument list
    at createScript (vm.js:80:10)
    at Object.runInThisContext (vm.js:139:10)
    at Module._compile (module.js:617:28)
    at Object.Module._extensions..js (module.js:664:10)
    at Module.load (module.js:566:32)
    at tryModuleLoad (module.js:506:12)
    at Function.Module._load (module.js:498:3)
    at Function.Module.runMain (module.js:694:10)
    at startup (bootstrap_node.js:204:16)
    at bootstrap_node.js:625:3

√ create-yo ok!

My System:

  • Windows 10
  • Cmder
$ node -v  
v8.15.0    
$ npm -v
6.4.1

Am I doing something wrong?

Error: Cannot find module 'libnpx'

I have a fresh nodejs installation in Windows 10 (i have this issue in linux too)

I already verify npm cache:

C:\Users\almancini\prova>npm cache verify
Cache verified and compressed (~\AppData\Roaming\npm-cache\_cacache):
Content verified: 33 (5600959 bytes)
Index entries: 48
Finished in 0.176s

If i try to use licence generator with npm init:

C:\Users\almancini\prova>npm init yo license
npx: installed 15 in 2.756s
internal/modules/cjs/loader.js:638
    throw err;
    ^

Error: Cannot find module 'libnpx'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:636:15)
    at resolveFileName (C:\Users\almancini\AppData\Roaming\npm-cache\_npx\7728\node_modules\create-yo\node_modules\resolve-from\index.js:29:39)
    at resolveFrom (C:\Users\almancini\AppData\Roaming\npm-cache\_npx\7728\node_modules\create-yo\node_modules\resolve-from\index.js:43:9)
    at module.exports (C:\Users\almancini\AppData\Roaming\npm-cache\_npx\7728\node_modules\create-yo\node_modules\resolve-from\index.js:46:47)
    at module.exports (C:\Users\almancini\AppData\Roaming\npm-cache\_npx\7728\node_modules\create-yo\node_modules\import-from\index.js:4:55)
    at Object.<anonymous> (C:\Users\almancini\AppData\Roaming\npm-cache\_npx\7728\node_modules\create-yo\src\create-yo.js:8:13)
    at Module._compile (internal/modules/cjs/loader.js:776:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:787:10)
    at Module.load (internal/modules/cjs/loader.js:653:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:593:12)

NodeJS and npm version:

C:\Users\almancini\prova>npm -v
6.9.0

C:\Users\almancini\prova>node -v
v10.16.0

Not working for sub-generators

It seems like sub-generators are interpreted as a URL scheme, so the command fails to run correctly.

$ npm init yo generator:subgenerator eslint-config
✖ create-yo errored:

Error: Unsupported URL Type "generator:": generator:subgenerator

The same happened when trying to run create-yo through yarn create as well.

Running directly through npx did work, however

$ npx -p generator-generator -p yo -- yo generator:subgenerator eslint-config
   create generators/eslint-config/index.js
   create generators/eslint-config/templates/dummyfile.txt
   create __tests__/eslint-config.js

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.