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

Support template sources outside of npmjs.com #8844

Closed
andredigenova opened this issue Apr 16, 2020 · 5 comments
Closed

Support template sources outside of npmjs.com #8844

andredigenova opened this issue Apr 16, 2020 · 5 comments

Comments

@andredigenova
Copy link

Is your proposal related to a problem?

Using create-react-app templates outside of the npmjs.com ecosystem is painful. It seems the only viable way to do it is pull the code down yourself and use the file: syntax, or host a tarball somewhere.

This is fairly important for template code bases that are private since there doesn't appear to be a no-cost way of hosting private packages on npmjs.com.

Describe the solution you'd like

There are a couple solutions to this and I think both of them would be universally useful.

  • Support git repo URI syntax in the --template argument.
  • Support an argument to specify a 3rd party npm registry for the template

I'm sure there are probably others I didn't think of.

Describe alternatives you've considered

Setting a 3rd-party npm package registry on npm globally before running npx create-react-app seems to be broken. I tested it with Github's npm registry and it failed with an odd error part way through project setup.

All variations of git URI syntax I've tried don't seem to work and produce errors mostly related to cra-template getting injected when it shouldn't be.

Additional context

(Write your answer here.)

@ricardoamedeiros
Copy link

ricardoamedeiros commented Apr 21, 2020

Is your proposal related to a problem?

Using create-react-app templates outside of the npmjs.com ecosystem is painful. It seems the only viable way to do it is pull the code down yourself and use the file: syntax, or host a tarball somewhere.

This is fairly important for template code bases that are private since there doesn't appear to be a no-cost way of hosting private packages on npmjs.com.

Describe the solution you'd like

There are a couple solutions to this and I think both of them would be universally useful.

  • Support git repo URI syntax in the --template argument.
  • Support an argument to specify a 3rd party npm registry for the template

I'm sure there are probably others I didn't think of.

Describe alternatives you've considered

Setting a 3rd-party npm package registry on npm globally before running npx create-react-app seems to be broken. I tested it with Github's npm registry and it failed with an odd error part way through project setup.

All variations of git URI syntax I've tried don't seem to work and produce errors mostly related to cra-template getting injected when it shouldn't be.

Additional context

(Write your answer here.)

Hi @andredigenova,

I have the same problem. Your issue is similar the issue #8425.

I did all set up for private npm, but not working.

@ricardoamedeiros
Copy link

I discovered the problem. The template path within node_modules was not being found. I made the pull request with the following adjustment:

javascript:

create-react-app/packages/react-scripts/scripts/init.js

befor:

const templatePath = path.dirname( require.resolve(${templateName}/package.json, { paths: [appPath] }) );

after:

const templatePath = path.dirname( require.resolve(${templateName}/package.json, { paths: [${appPath}/node_modules] }) );

@mrmckeb
Copy link
Contributor

mrmckeb commented Apr 29, 2020

Hi @andredigenova,

This should work fine with third-party registries. I use it with Verdaccio on a work-related project. Can you please share your template?

Also, note that templates are required to have a main field in them to work until our next release, see:
e0b179c#diff-1453d9590326c639309801105bc967c2

@ricardoamedeiros
Copy link

With field "main" in package.json worked.

@mrmckeb
Copy link
Contributor

mrmckeb commented Apr 29, 2020

Thanks for the update! I'll close this off. Sorry again, we'll get the fix out ASAP.

@mrmckeb mrmckeb closed this as completed Apr 29, 2020
@lock lock bot locked and limited conversation to collaborators May 5, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants