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

Project generation with --scripts-version=react-native-scripts-ts and --with-web-support not working #19

Open
codeflowee opened this issue Aug 30, 2018 · 0 comments

Comments

@codeflowee
Copy link

codeflowee commented Aug 30, 2018

Description

When generating new project with create-react-native-app my-new-app --scripts-version=react-native-scripts-ts --with-web-support

Observed Behavior

I ran npm run web and problems were following:

  • Wrong path for index file in webpack config
ERROR in multi (webpack)-dev-server/client?http://localhost:8080 webpack/hot/dev-server ./src/index.js
Module not found: Error: Can't resolve 'path-to/payrest/my-new-app/src/index.js' in 'path-to/payrest/my-new-app'
 @ multi (webpack)-dev-server/client?http://localhost:8080 webpack/hot/dev-server ./src/index.js

For this I just changed

entry: path.resolve(appDirectory, 'src/index.js'),

to

entry: path.resolve(appDirectory, 'src/index.tsx'),
  • After changing entry problems with registerServiceWorker.js, it should be changed to typescript relevant, for an example I took one generated with create-react-app and changed to registerServiceWorker.ts

  • Need to install yarn add @types/react-dom -D to get rid of TypeScript errors in index.tsx

  • Then when running npm run web once again I get:

ERROR in ./src/index.tsx
Module parse failed: Unexpected token (7:16)
You may need an appropriate loader to handle this file type.
| import registerServiceWorker from './registerServiceWorker';
|
| ReactDOM.render(<App />, document.getElementById('root'));
| registerServiceWorker();
|
 @ multi (webpack)-dev-server/client?http://localhost:8080 webpack/hot/dev-server ./src/index.tsx

This is the place where I stopped.

Is there any easier solution to get it running?

Environment

  1. Operating system:
ProductName:    Mac OS X
ProductVersion: 10.13.6
BuildVersion:   17G65
@codeflowee codeflowee changed the title Project generation with --scripts-version=react-native-scripts-ts and --with-web-support not working Project generation with --scripts-version=react-native-scripts-ts and --with-web-support not working Aug 30, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant