LunatiqueCoder / luna

Luna - a React Native + Next.js template. Built with TypeScript :heart:
https://luna-gamma.vercel.app/
MIT License
264 stars 17 forks source link

yarn create luna-app fails generating expo #82

Open jonsherrard opened 1 year ago

jonsherrard commented 1 year ago

Describe the bug

The CLI tool yarn create luna-app fails during the creation of a project with expo for RN


Node.js v18.13.0
error Command failed.
Exit code: 1
Command: /opt/homebrew/bin/create-expo-app
Arguments: my-luna-app --template @create-luna-app/expo@latest
Directory: /Users/jonsherrard/projects/solito-apps
Output:

    at ChildProcess.exithandler (node:child_process:419:12)
    at ChildProcess.emit (node:events:513:28)
    at maybeClose (node:internal/child_process:1091:16)
    at ChildProcess._handle.onexit (node:internal/child_process:302:5) {
  code: 1,
  killed: false,
  signal: null,
  cmd: 'yarn create expo-app my-luna-app --template @create-luna-app/expo@latest',
  stdout: 'yarn create v1.22.19\n' +
    '[1/4] Resolving packages...\n' +
    '[2/4] Fetching packages...\n' +
    '[3/4] Linking dependencies...\n' +
    '[4/4] Building fresh packages...\n' +
    'success Installed "create-expo-app@1.3.2" with binaries:\n' +
    '      - create-expo-app\n' +
    'info Visit https://yarnpkg.com/en/docs/cli/create for documentation about this command.\n',
  stderr: '⠋ Locating project files.⠙ Locating project files.⠹ Locating project files.⠸ Locating project files.⠼ Locating project files.node:events:491\n' +
    "      throw er; // Unhandled 'error' event\n" +
    '      ^\n' +
    '\n' +
    "Error: ENOENT: no such file or directory, open '/var/folders/lv/hg_m8flx56z455spv6qfnx5h0000gn/T/.create-expo-app/template-cache/@create-luna-app/expo-3.0.3.tgz'\n" +
    "Emitted 'error' event on ReadStream instance at:\n" +
    '    at emitErrorNT (node:internal/streams/destroy:151:8)\n' +
    '    at emitErrorCloseNT (node:internal/streams/destroy:116:3)\n' +
    '    at process.processTicksAndRejections (node:internal/process/task_queues:82:21) {\n' +
    '  errno: -2,\n' +
    "  code: 'ENOENT',\n" +
    "  syscall: 'open',\n" +
    "  path: '/var/folders/lv/hg_m8flx56z455spv6qfnx5h0000gn/T/.create-expo-app/template-cache/@create-luna-app/expo-3.0.3.tgz'\n" +
    '}\n' +
    '\n' +
    'Node.js v18.13.0\n' +
    'error Command failed.\n' +
    'Exit code: 1\n' +
    'Command: /opt/homebrew/bin/create-expo-app\n' +
    'Arguments: my-luna-app --template @create-luna-app/expo@latest\n' +
    'Directory: /Users/jonsherrard/projects/solito-apps\n' +
    'Output:\n' +
    '\n'
}
LunatiqueCoder commented 1 year ago

Hello @jonsherrard

I will be able to have a look later today

Meanwhile, what if you try yarn create expo-app MyApp --template @create-luna-app/expo?

jonsherrard commented 1 year ago

same error:

Error: ENOENT: no such file or directory, open '/var/folders/lv/hg_m8flx56z455spv6qfnx5h0000gn/T/.create-expo-app/template-cache/@create-luna-app/expo-3.0.3.tgz'
LunatiqueCoder commented 1 year ago

@jonsherrard perhaps try an older version? 🙈

yarn create expo-app MyApp --template @create-luna-app/expo@3.0.2

yarn create expo-app MyApp --template @create-luna-app/expo@3.0.1

yarn create expo-app MyApp --template @create-luna-app/expo@3.0.0

LunatiqueCoder commented 1 year ago

@jonsherrard I'm sorry but I'm not sure that I can reproduce it...

it seems to me that there's some sort of Yarn cache issue. Perhaps if you could also try to clear it? Even navigating to /var/folders/lv/hg_m8flx56z455spv6qfnx5h0000gn/T/.create-expo-app/template-cache/@create-luna-app/expo-3.0.3.tgz and delete it might solve the issue, but I really have no other clue.

You can also check the source code here: https://github.com/LunatiqueCoder/luna/tree/master/templates/expo

I believe the most important part is this line of code here: https://github.com/LunatiqueCoder/luna/blob/master/templates/expo/next.config.js#L55

jonsherrard commented 1 year ago

real strange. That folder doesn't exist, I tried deleted everything in the hg_xxxx folder

I've tried Yarn 1, and Yarn 3.5 same errors.

Will report back if I find the fix.

leogilmour commented 1 year ago

This failed for me in 2 different ways.

First: yarn 1.22.17

yarn create luna-app
yarn create v1.22.17
[1/4] 🔍  Resolving packages...
[2/4] 🚚  Fetching packages...
[3/4] 🔗  Linking dependencies...
[4/4] 🔨  Building fresh packages...
success Installed "create-luna-app@3.0.3" with binaries:
      - create-luna-app
[#] 347/347?
✔ What is the name of the app? · the-rsvp
✔ Choose your CLI · Expo
✔ Installed!
yarn create v1.22.17
[1/4] Resolving packages...
[2/4] Fetching packages...
[3/4] Linking dependencies...
[4/4] Building fresh packages...
success Installed "create-expo-app@1.3.2" with binaries:
      - create-expo-app
Done in 6.59s.

✨  Done in 14.43s.

When I looked in the directory, there was nothing there. Just an empty yarn.lock file.

so then I upgraded yarn.

Second: v1.22.19

[1/4] 🔍  Resolving packages...
[2/4] 🚚  Fetching packages...
[3/4] 🔗  Linking dependencies...
[4/4] 🔨  Building fresh packages...
success Installed "create-luna-app@3.0.3" with binaries:
      - create-luna-app
[#] 349/349?
✔ What is the name of the app? · the-rsvp
✔ Choose your CLI · Expo
⠴ Creating your 🌘 Luna app.../Users/leogilmour/.config/yarn/global/node_modules/gluegun/build/index.js:15
    throw up;
    ^

Error: Command failed: yarn create expo-app the-rsvp --template @create-luna-app/expo@latest
⠋ Locating project files.⠙ Locating project files.⠹ Locating project files.⠸ Locating project files.⠼ Locating project files.⠴ Locating project files.⠦ Locating project files.⠧ Locating project files.⠇ Locating project files.⠏ Locating project files.⠋ Locating project files.⠙ Locating project files.⠹ Locating project files.⠸ Locating project files.⠼ Locating project files.⠴ Locating project files.⠦ Locating project files.⠧ Locating project files.⠇ Locating project files.⠏ Locating project files.node:events:491
      throw er; // Unhandled 'error' event
      ^

Error: ENOENT: no such file or directory, open '/var/folders/m3/tks6n_q56z32bc5s48kc5r4w0000gn/T/.create-expo-app/template-cache/@create-luna-app/expo-3.0.3.tgz'
Emitted 'error' event on ReadStream instance at:
    at emitErrorNT (node:internal/streams/destroy:151:8)
    at emitErrorCloseNT (node:internal/streams/destroy:116:3)
    at process.processTicksAndRejections (node:internal/process/task_queues:82:21) {
  errno: -2,
  code: 'ENOENT',
  syscall: 'open',
  path: '/var/folders/m3/tks6n_q56z32bc5s48kc5r4w0000gn/T/.create-expo-app/template-cache/@create-luna-app/expo-3.0.3.tgz'
}

Node.js v19.0.1
error Command failed.
Exit code: 1
Command: /usr/local/bin/create-expo-app
Arguments: the-rsvp --template @create-luna-app/expo@latest
Directory: /Users/leogilmour/code/luna
Output:

    at ChildProcess.exithandler (node:child_process:412:12)
    at ChildProcess.emit (node:events:513:28)
    at maybeClose (node:internal/child_process:1098:16)
    at Socket.<anonymous> (node:internal/child_process:456:11)
    at Socket.emit (node:events:513:28)
    at Pipe.<anonymous> (node:net:298:12) {
  code: 1,
  killed: false,
  signal: null,
  cmd: 'yarn create expo-app the-rsvp --template @create-luna-app/expo@latest',
  stdout: 'yarn create v1.22.19\n' +
    '[1/4] Resolving packages...\n' +
    '[2/4] Fetching packages...\n' +
    '[3/4] Linking dependencies...\n' +
    '[4/4] Building fresh packages...\n' +
    'success Installed "create-expo-app@1.3.2" with binaries:\n' +
    '      - create-expo-app\n' +
    'info Visit https://yarnpkg.com/en/docs/cli/create for documentation about this command.\n',
  stderr: '⠋ Locating project files.⠙ Locating project files.⠹ Locating project files.⠸ Locating project files.⠼ Locating project files.⠴ Locating project files.⠦ Locating project files.⠧ Locating project files.⠇ Locating project files.⠏ Locating project files.⠋ Locating project files.⠙ Locating project files.⠹ Locating project files.⠸ Locating project files.⠼ Locating project files.⠴ Locating project files.⠦ Locating project files.⠧ Locating project files.⠇ Locating project files.⠏ Locating project files.node:events:491\n' +
    "      throw er; // Unhandled 'error' event\n" +
    '      ^\n' +
    '\n' +
    "Error: ENOENT: no such file or directory, open '/var/folders/m3/tks6n_q56z32bc5s48kc5r4w0000gn/T/.create-expo-app/template-cache/@create-luna-app/expo-3.0.3.tgz'\n" +
    "Emitted 'error' event on ReadStream instance at:\n" +
    '    at emitErrorNT (node:internal/streams/destroy:151:8)\n' +
    '    at emitErrorCloseNT (node:internal/streams/destroy:116:3)\n' +
    '    at process.processTicksAndRejections (node:internal/process/task_queues:82:21) {\n' +
    '  errno: -2,\n' +
    "  code: 'ENOENT',\n" +
    "  syscall: 'open',\n" +
    "  path: '/var/folders/m3/tks6n_q56z32bc5s48kc5r4w0000gn/T/.create-expo-app/template-cache/@create-luna-app/expo-3.0.3.tgz'\n" +
    '}\n' +
    '\n' +
    'Node.js v19.0.1\n' +
    'error Command failed.\n' +
    'Exit code: 1\n' +
    'Command: /usr/local/bin/create-expo-app\n' +
    'Arguments: the-rsvp --template @create-luna-app/expo@latest\n' +
    'Directory: /Users/leogilmour/code/luna\n' +
    'Output:\n' +
    '\n'
}

Node.js v19.0.1
error Command failed.
Exit code: 1
Command: /usr/local/bin/create-luna-app
Arguments: 
Directory: /Users/leogilmour/code/luna
Output:

info Visit https://yarnpkg.com/en/docs/cli/create for documentation about this command.
LunatiqueCoder commented 1 year ago

@leogilmour

Those issues might be related. yarn cache clean might be helpful. I'll also investigate this on my side, but everything is working fine so far :/ I'm on yarn v1.22.19

Also, here's the Expo template on npm: https://www.npmjs.com/package/@create-luna-app/expo?activeTab=code

LunatiqueCoder commented 1 year ago

@leogilmour @jonsherrard Are you guys using Ubuntu or Windows? I kept trying to see what's your issue but I can't find anything useful... I actually started building an app with the Expo template and everything is going well 🙈

jonsherrard commented 1 year ago

both on osx

LunatiqueCoder commented 1 year ago

I asked a few friends to try it out and they all confirmed it also works on their side. I really have no idea what's wrong here.

Except from pasting links that you probably also found in your searches, I'm a little bit clueless.

https://bobbyhadz.com/blog/npm-command-not-found-yarn#:~:text=To%20solve%20the%20error%20%22yarn,in%20your%20system's%20environment%20variable.

Perhaps if you clone the repo, run cd templates/expo to go to the Expo template and then run yarn link, it will work by using your local version when you run again yarn create luna-app

LunatiqueCoder commented 1 year ago

Any luck here? I might have an idea for another workaround, but it will take about 1 week for me to be able to implement it, hopefully it won't be too late for you. 🙈

leogilmour commented 1 year ago

so i ended up cloning and getting it working that way :)

just went into the repo i got working (the manual way) and yarn linked. tried creating a new project, just to test it for you! still getting the same issue 🤷 But I'm all set now having just cloned and isolated the relevant folder :)

LunatiqueCoder commented 1 year ago

Happy to hear that! Let me know if you need further help. I just started documenting how to implement Firebase with phone number authentication and Cloud Firestore DB using (almost) the same API for native and web. Also for i18next there's even an easier setup to work seamlessly between platforms. Cheers

LunatiqueCoder commented 1 year ago

Hello @trubesv

Thank you for trying out the template! Unfortunately, I really don't know what's the issue with some people. But I think you are on a good path by cloning the project.

error TS6053: File 'expo/tsconfig.base' not found.

This is probably an issue with the tsconfig.json file. Try to quit and reopen your code editor (this usually works for some typescript errors lol). Have you tried to run the app nevertheless?

EDIT:

Alternatively, you can try to check if the file exists in node_modules:

image



EDIT2:

By the way, expo-router v2 introduces static rendered routes for web and in some future versions they also want to support server side rendering and React Server Components. So in my opinion, trying to use Next.js with React Native will be an useless headache compared to what Expo will offer. But that's just my opinion, don't take it for granted.

LunatiqueCoder commented 1 year ago

Note that at this point the command is still running, and http://localhost:3000/ hangs!

I'm really not sure what happens there, but seems you're close to make it work. 🙈 I guess it's an issue with Yarn Plug N Play, not sure if this package supports it. My first search on google (but I guess you already came across this): https://stackoverflow.com/questions/76015181/the-yarn-plugnplay-manifest-forbids-importing-xyz-here-because-its-not-list

I also stumbled upon https://github.com/tamagui/tamagui/tree/master/starters/next-expo-solito, so I'm wondering which one is the subjective "best" way to create a modern app for these 3 platforms with a unique codebase.

This uses a monorepo and in my opinion introduces a lot of complexity just because of this. Looks more like an enterprise starter.

I'm looking for the most complete, state of the art, out of the box experience.

My opinion:

Regarding your second edit, would you advise against using your template?

Not really, depends on what you're looking for. I started with Next.js + Expo for the more complete experience but eventually I decided to stick just with Expo for now since I'm working alone on my pet project and I really need to move fast. Also, Expo (with expo-router) will support Next.js features out of the box, so in the future, this Solito (Next.js + Expo) stack might really be pointless.

For example

So when my app is ready I will just start using those features with Expo if they are also ready. Refactoring will be easier I guess.