Skip to content
This repository has been archived by the owner on Jan 18, 2024. It is now read-only.

Expo issues with npm scripts on Windows #51

Closed
xpsdeset opened this issue Sep 27, 2018 · 13 comments · Fixed by expo/expo#2853
Closed

Expo issues with npm scripts on Windows #51

xpsdeset opened this issue Sep 27, 2018 · 13 comments · Fixed by expo/expo#2853
Assignees
Labels

Comments

@xpsdeset
Copy link

xpsdeset commented Sep 27, 2018

Description

I want to use global expo for my npm scripts.
Since latest versions exp command has been renamed to expo
Again expo is installed globally and works fine when I do "expo start"
But for some reasons I love to do it via npm scripts. Like yarn start

Expected Behavior

Below is my simple scripts sections from my package.json

"scripts": {
    "start": "expo start",
  }

Observed Behavior

I get this error.

This command requires Expo CLI.
Do you want to install it globally [Y/n]?

Environment

My expo diagnostics


Environment:
  OS: Windows 10
  Node: 8.11.1
  Yarn: 1.9.2
  npm: 5.7.1
  Watchman: Not Found
  Xcode: N/A
  Android Studio: Not Found

Packages: (wanted => installed)
  expo: ^30.0.1 => 30.0.1
  react: 16.3.1 => 16.3.1
  react-native: https://github.com/expo/react-native/archive/sdk-30.0.0.tar.gz => 0.55.4

Diagnostics report:
  https://exp-xde-diagnostics.s3.amazonaws.com/sykiks_team-c09f9814-34a7-4afe-ac74-162432e9361a.tar.gz

I investigated and found out it picks up the expo from node_modules/.bin and not global one. Which obviously explains. If I remove expo and expo.cmd than it works but after every yarn installation it get added back.

@incorelabs
Copy link

@xpsdeset I am also facing a similar issue. Did this get resolved for you? If so how? :)

Apart from that I am also facing issues with switching back and forth from development mode to production mode. Once, in production mode it is nearly impossible to get it back to development mode. Are you facing an issues on a similar line?

@xpsdeset
Copy link
Author

xpsdeset commented Oct 3, 2018

As I said. go to your local node_modules folder. There will be a .bin folder
Remove expo and expo.cmd
Its a temporary fix. As whenever you add a new node module, those 2 files reappear

@rodrigowpl
Copy link

The same problem here, I can't start and don't even start in android

@minhthanh310
Copy link

I see the error at this code (node_modules\expo\bin\cli.js)
spawn('expo-cli', process.argv.slice(2), { stdio: 'inherit' })

Probably it's the bug of child_process on Window when spawn .bat or .cmd file, the suggest fix is:
spawn('expo-cli', process.argv.slice(2), { stdio: 'inherit', shell: true })

@louistiti
Copy link

Until there, downgrading to 26.1.1 made the fix for me.

@fhelwanger
Copy link

fhelwanger commented Oct 24, 2018

As a workaround, I installed "rimraf" as a dev dependency and put this at the beginning of each of my scripts:

rimraf node_modules/.bin/expo* &&

This way, I don't need to tell each developer to delete the files manually every yarn install until it's fixed 😄

@renanwilliam
Copy link

same problem here, removing expo and expo.cmd works as workaround

@cmacdonnacha
Copy link

Same issue here

@AgainPsychoX
Copy link

Same issue :C

@Pandawan
Copy link

Same issue, made a fresh expo project and immediately got the issue.

@bkniffler
Copy link

Wasting some significant time on this. Its been known for a few weeks and makes developer experience super frustrating. Can this be fixed? @minhthanh310 seems like a decent fix.

colemanja91 added a commit to firstleads/heaven that referenced this issue Nov 27, 2018
@fson fson self-assigned this Nov 29, 2018
@fson
Copy link
Contributor

fson commented Nov 29, 2018

I'm working on a fix for the next expo package version.

Until it ships, if you're using Windows, you can temporarily work around the issue by replacing the expo command with expo-cli in your npm scripts, for example:

  "scripts": {
    "start": "expo-cli start",
    "android": "expo-cli start --android",
    "ios": "expo-cli start --ios",
    "eject": "expo-cli eject",
    "test": "node ./node_modules/jest/bin/jest.js --watchAll"
  },

Sorry about the trouble.

@fson fson changed the title Expo issues with npm scripts. Expo issues with npm scripts on Windows Nov 29, 2018
@fson
Copy link
Contributor

fson commented Dec 4, 2018

The fix has been released in the version 31.0.6 of the expo package. The workaround described above is no longer necessary when using expo@31.0.6 or later.

@lock lock bot added the outdated label Jul 1, 2019
@lock lock bot locked and limited conversation to collaborators Jul 1, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.