Skip to content
This repository has been archived by the owner on Dec 1, 2022. It is now read-only.

Can't use cli on windows #4

Closed
francesco-clementi-92 opened this issue Oct 17, 2020 · 21 comments
Closed

Can't use cli on windows #4

francesco-clementi-92 opened this issue Oct 17, 2020 · 21 comments
Labels
bug Something isn't working help wanted Extra attention is needed

Comments

@francesco-clementi-92
Copy link

francesco-clementi-92 commented Oct 17, 2020

Can't use the cli on windows 10 with node js 10 or 12:

Creating myapp, brought to you by webRidge.

  Please wait till everything is finished :)



Could not create React Native project {
  error: Error: spawn npx ENOENT
      at Process.ChildProcess._handle.onexit (internal/child_process.js:267:19)
      at onErrorNT (internal/child_process.js:469:16)
      at processTicksAndRejections (internal/process/task_queues.js:84:21) {
    errno: 'ENOENT',
    code: 'ENOENT',
    syscall: 'spawn npx',
    path: 'npx',
    spawnargs: [ 'react-native', 'init', 'larted' ]
  }
}

 Created two projects in two directories. Let's merge them to one project ;)

(node:8384) UnhandledPromiseRejectionWarning: Error: ENOENT: no such file or directory, open 'larted-web-will-be-deleted-afterwards/package.json'
    at Object.openSync (fs.js:462:3)
    at Object.readFileSync (fs.js:364:35)
    at C:\Users\cico\AppData\Roaming\npm-cache\_npx\8384\node_modules\create-react-native-web-application\dist\index.js:58:29
    at Generator.throw (<anonymous>)
    at asyncGeneratorStep (C:\Users\cico\AppData\Roaming\npm-cache\_npx\8384\node_modules\create-react-native-web-application\dist\index.js:10:103)
    at _throw (C:\Users\cico\AppData\Roaming\npm-cache\_npx\8384\node_modules\create-react-native-web-application\dist\index.js:12:291)
    at processTicksAndRejections (internal/process/task_queues.js:97:5)
(node:8384) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:8384) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.``` 
@RichardLindhout
Copy link
Member

Maybe it could not create the larted-web because it contains the '-' sign, could you try lartedweb?
I think React Native cli prevents project from creating names like this which results in this error

@francesco-clementi-92
Copy link
Author

Actually the name I used with cli is just larted.

I just tried npx create-react-native-web-application --name larted

@RichardLindhout
Copy link
Member

what happens if you try to run

react-native init larted

It looks like this does crash somehow

@francesco-clementi-92
Copy link
Author

No problem with this command

@RichardLindhout
Copy link
Member

Hmm. I don't know how to fix it since I don't have a windows machine I would accept a PR which fixes this error!

@RichardLindhout RichardLindhout added bug Something isn't working help wanted Extra attention is needed labels Nov 26, 2020
@paolospag
Copy link

I experienced the same issue.
Apparentely seems to be caused by spawn method on Windows... so I tried to google for that and I found this resource:
nodejs/node-v0.x-archive#5841 (comment)

@RichardLindhout could help you solve the problem?

@RichardLindhout
Copy link
Member

New version released. Does it work now?

@paolospag
Copy link

I personally tried using create-react-native-web-application for the first time about an hour ago and it didn't work.

I had the same error mentioned above.

So I ask you, which latest version are you referring to? Is there any way to specify the version in the command?

@RichardLindhout
Copy link
Member

npx always downloads latest version

@paolospag
Copy link

Therefore, I can confirm that on Windows it still does not work

@RichardLindhout
Copy link
Member

Released a newer version again. What is the result now?

@paolospag
Copy link

ok... the latest version completes the process and seems to work, but something went wrong with configuration/merging because if I try to run npm run web it says that react-app-rewired is not installed.

This is package.json at the end of the process (is that right?):

{
  "name":"ridgetest",
  "version":"0.1.0",
  "private":true,
  "scripts":{
    "android":"react-native run-android",
    "ios":"react-native run-ios",
    "start":"react-native start",
    "test":"jest",
    "lint":"eslint .",
    "web:build":"react-app-rewired build",
    "web:test":"react-app-rewired test",
    "web:eject":"react-app-rewired eject",
    "web":"react-app-rewired start"
  },
  "dependencies":{
    "react":"16.13.1",
    "react-native":"0.63.4"
  },
  "devDependencies":{
    "@babel/core":"^7.8.4",
    "@babel/runtime":"^7.8.4",
    "@react-native-community/eslint-config":"^1.1.0",
    "babel-jest":"^25.1.0",
    "eslint":"^6.5.1",
    "jest":"^25.1.0",
    "metro-react-native-babel-preset":"^0.59.0",
    "react-test-renderer":"16.13.1"
  },
  "jest":{
    "preset":"react-native"
  },
  "eslintConfig":{
    "extends":[
      "react-app",
      "react-app/jest"
    ]
  },
  "browserslist":{
    "production":[
      ">0.2%",
      "not dead",
      "not op_mini all"
    ],
    "development":[
      "last 1 chrome version",
      "last 1 firefox version",
      "last 1 safari version"
    ]
  }
}

@RichardLindhout
Copy link
Member

RichardLindhout commented Dec 30, 2020

Strange it should be

{
  "name": "myappname",
  "version": "0.1.0",
  "private": true,
  "scripts": {
    "android": "react-native run-android",
    "ios": "react-native run-ios",
    "start": "react-native start",
    "test": "jest",
    "lint": "eslint .",
    "web:build": "react-app-rewired build",
    "web:test": "react-app-rewired test",
    "web:eject": "react-app-rewired eject",
    "web": "react-app-rewired start"
  },
  "dependencies": {
    "react": "^17.0.1",
    "react-dom": "^17.0.1",
    "react-native": "0.63.4",
    "react-native-web": "^0.14.10",
    "react-scripts": "4.0.1"
  },
  "devDependencies": {
    "@babel/core": "^7.12.10",
    "@babel/runtime": "^7.12.5",
    "@react-native-community/eslint-config": "^2.0.0",
    "@testing-library/jest-dom": "^5.11.4",
    "@testing-library/react": "^11.1.0",
    "@testing-library/user-event": "^12.1.10",
    "@types/react": "^17.0.0",
    "@types/react-native": "^0.63.43",
    "babel-jest": "^26.6.3",
    "babel-plugin-import": "^1.13.3",
    "customize-cra": "^1.0.0",
    "eslint": "^7.16.0",
    "jest": "^26.6.3",
    "metro-react-native-babel-preset": "^0.64.0",
    "react-app-rewired": "^2.1.8",
    "react-test-renderer": "16.13.1",
    "typescript": "^4.1.3"
  },
  "jest": {
    "preset": "react-native"
  },
  "eslintConfig": {
    "extends": [
      "react-app",
      "react-app/jest"
    ]
  },
  "browserslist": {
    "production": [
      ">0.2%",
      "not dead",
      "not op_mini all"
    ],
    "development": [
      "last 1 chrome version",
      "last 1 firefox version",
      "last 1 safari version"
    ]
  }
}

@RichardLindhout
Copy link
Member

@RichardLindhout
Copy link
Member

I think I'll try out https://www.npmjs.com/package/cross-spawn

@RichardLindhout
Copy link
Member

I now use cross-spawn and I hope it will resolve the issues on Windows. I really like the help you're giving me ;)

Can you try it again?

@paolospag
Copy link

paolospag commented Dec 30, 2020

mmh, there is still something wrong... the process now stops at this step:
Created two projects in two directories. Let's merge them to one project ;)

This is the error on shell:

(node:12184) UnhandledPromiseRejectionWarning: Error: spawn yarn ENOENT
    at notFoundError (C:\Users\JohnDoe\AppData\Roaming\npm-cache\_npx\12184\node_modules\create-react-native-web-application\node_modules\cross-spawn\lib\enoent.js:6:26)
    at verifyENOENT (C:\Users\JohnDoe\AppData\Roaming\npm-cache\_npx\12184\node_modules\create-react-native-web-application\node_modules\cross-spawn\lib\enoent.js:40:16)
    at ChildProcess.cp.emit (C:\Users\JohnDoe\AppData\Roaming\npm-cache\_npx\12184\node_modules\create-react-native-web-application\node_modules\cross-spawn\lib\enoent.js:27:25)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:272:12)
(node:12184) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:12184) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

I apologize because I would like to help you with a pull request, but I don't know where to start 😅

@RichardLindhout
Copy link
Member

Ok lol I use yarn to install extra packages can you install it? It is a npm alternative with less problems

@paolospag
Copy link

ok, I have installed yarn globally and the process is completed successfull, but it should not be mandatory or it should be specified in the readme.

anyway, now everything works correctly.. well done! 🥳

@RichardLindhout
Copy link
Member

I agree

@RichardLindhout
Copy link
Member

I have added this to the README.md.

Thanks for following up and testing 👍 !

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

3 participants