VasilyShelkov / create-react-extension

Set up a modern React browser extension by running one command.
MIT License
345 stars 39 forks source link

npx create-react-app my-browser-extension --scripts-version react-browser-extension-scripts doesn't work #13

Closed RusseII closed 4 years ago

RusseII commented 4 years ago

Could not locate supplied template: /Users/russell/code/cra-template MacBook-Pro-2:code russell$ cd my-browser-extension MacBook-Pro-2:my-browser-extension russell$ ls node_modules package.json yarn.lock MacBook-Pro-2:my-browser-extension russell$ npm start

VasilyShelkov commented 4 years ago

Sorry, I'll take a look today.

I haven't been actively keeping this up to date in the last month but I'm planning on carrying on maintaining it this month especially knowing someone else is trying to use it

hholmes commented 4 years ago

I'm having the same problem identically. cra-template not found, and yarn start generates the following:

> yarn start
yarn run v1.21.1
$ react-scripts start
Could not find a required file.
  Name: popup.html
  Searched in: / <root> /public
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

Out of curiosity I copied over a cra-template from create-react-app and this happened instead:

/ <root> /node_modules/react-browser-extension-scripts/scripts/init.js:153
      throw err;
      ^

Error: ENOENT: no such file or directory, link '/ <root> /gitignore' -> '/ <root> /.gitignore'
    at Object.linkSync (fs.js:1035:3)
    at tryRenameSync (/ <root> /node_modules/fs-extra/lib/move-sync/index.js:40:12)
    at Object.moveSync (/ <root> /node_modules/fs-extra/lib/move-sync/index.js:22:3)
    at module.exports (/ <root> /node_modules/react-browser-extension-scripts/scripts/init.js:141:8)
    at [eval]:3:14
    at Script.runInThisContext (vm.js:116:20)
    at Object.runInThisContext (vm.js:306:38)
    at Object.<anonymous> ([eval]-wrapper:9:26)
    at Module._compile (internal/modules/cjs/loader.js:971:30)
    at evalScript (internal/process/execution.js:80:25) {
  errno: -2,
  syscall: 'link',
  code: 'ENOENT',
  path: '/ <root> /gitignore',
  dest: '/ <root> /.gitignore'
}

Aborting installation.
  node  has failed.

Deleting generated file... node_modules
Deleting generated file... package.json
Deleting generated file... yarn.lock
Done.
error Command failed.
Exit code: 1
Command: /usr/local/bin/create-react-app
Arguments: composr3 --scripts-version react-browser-extension-scripts
Directory: / <root>
Output:

info Visit https://yarnpkg.com/en/docs/cli/create for documentation about this command.
VasilyShelkov commented 4 years ago

Hi, I've unfortunately still not had some free time to look at this yet. I have put time aside to resolve this issue on the weekend. Thank you for any extra info given from anyone in advance

L4suicide commented 4 years ago

I get the same issue - was very keen to try this out though!

VasilyShelkov commented 4 years ago

Short update: I've made some headway in debugging the issue. Think I should be able to resolve it and get something out by tomorrow morning.

dalmo3 commented 4 years ago

Thanks for your work, Vasily. Same error here.

I actually tried the same thing as @hholmes, with the same result. Then I manually copied the gitignore file and the installation finished with no error messages. But in reality there was lots of missing files and wouldn't work.

VasilyShelkov commented 4 years ago

Soooo.... It's not ideal, I'm still looking into this because I've only managed to catch pockets of time. I'm really keen to get this resolved BUT in the meantime if you anyone wants to use this. Temporarily you could:

  1. Clone this fork locally.
  2. Run yarn create-react-app my-browser-extension at the root of /create-react-extension.
  3. Then move the generated /my-browser-extension into your projects folder.

I just checked ^^ against master and seems to be working fine which makes me think that the npx generate command from the original Create-React-App repository has changed which is why it's failing to find the template and causing errors.

VasilyShelkov commented 4 years ago

So I've found the cause and almost have fixed the package to work with CRA V3.3.0.

The problem was that the main package has refactored the template into seperate packages to give more flexibility for developers: https://github.com/facebook/create-react-app/blob/master/CHANGELOG.md#330-2019-12-04

I am 90% sure I'll get a working version out today. This will mean the npx command will need updating which I'll do in the docs 🎉

VasilyShelkov commented 4 years ago

I have published the fixes, updated the readme and tested. It seems to be now working and compatible with CRA V3.3.0+.

Updated readme command: https://github.com/VasilyShelkov/create-react-extension#quick-overview

To use this package as an example use: npx create-react-app my-browser-extension --scripts-version react-browser-extension-scripts --template browser-extension

OR

npx create-react-app my-browser-extension --scripts-version react-browser-extension-scripts --template browser-extension-typescript for the typescript version.

Thanks all for your patience and reporting the issues. Sorry it took longer than I would have liked. I will try to be better in future