Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not working with npx #8

Open
Graham42 opened this issue Jan 21, 2018 · 4 comments
Open

Not working with npx #8

Graham42 opened this issue Jan 21, 2018 · 4 comments

Comments

@Graham42
Copy link

Graham42 commented Jan 21, 2018

Instead of installing anything globally, I've moved to use npx which comes with npm 5, which is default with node 8

Expected this to work:

$ npx -p generate -p generate-license gen license

Instead I get this error trace

$ npx -p generate -p generate-license gen license
npx: installed 1432 in 18.068s
[14:41:45] starting generate
[14:41:45] ✔ running tasks: [ 'license' ]
Error: Cannot find generator: "license" in "/home/grahamm/<project_dir>"
    at Generate.<anonymous> (/home/grahamm/.npm/_npx/7206/lib/node_modules/generate/node_modules/base-generators/index.js:499:18)
    at iterate (/home/grahamm/.npm/_npx/7206/lib/node_modules/generate/node_modules/async-each-series/index.js:8:5)
    at Function.module.exports (/home/grahamm/.npm/_npx/7206/lib/node_modules/generate/node_modules/async-each-series/index.js:20:3)
    at Generate.generate (/home/grahamm/.npm/_npx/7206/lib/node_modules/generate/node_modules/base-generators/index.js:492:15)
    at /home/grahamm/.npm/_npx/7206/lib/node_modules/generate/node_modules/base-generators/index.js:475:18
    at iterate (/home/grahamm/.npm/_npx/7206/lib/node_modules/generate/node_modules/async-each-series/index.js:8:5)
    at Function.module.exports (/home/grahamm/.npm/_npx/7206/lib/node_modules/generate/node_modules/async-each-series/index.js:20:3)
    at Generate.generate (/home/grahamm/.npm/_npx/7206/lib/node_modules/generate/node_modules/base-generators/index.js:474:24)
    at Generate.generate (/home/grahamm/.npm/_npx/7206/lib/node_modules/generate/node_modules/base-generators/index.js:463:23)
    at /home/grahamm/.npm/_npx/7206/lib/node_modules/generate/bin/generate.js:117:11
@jonschlinkert
Copy link
Member

What is npx? Is that a license supported by https://github.com/github/choosealicense.com (as stated on the readme)?

@jonschlinkert
Copy link
Member

Oh, I see, npx is something else. I don't know anything about npm, so I might need to rely on someone else to help.

That error message isn't very helpful, I'll look into why it's happening, but it might be something to do with npx

@Graham42
Copy link
Author

@doowb
Copy link
Member

doowb commented Jan 25, 2018

@Graham42 I just looked into this some.

When using npx with the -p flag, npx will download the package into a temporary "global" folder. The way generate works is that it will look for modules in the actual npm global folder, local node_modules folder, and for a local generator.js file. Since npx is putting generate-license into a temporary folder, generate doesn't know where to find it.

I tried this out by installing generate-license locally: npm i generate-license, then I was able to run npx like this: npx -p generate gen license.

I'm not sure if there's anything we can do since npx is creating temporary directories sometimes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants