Typescript in Existing React Project - javascript

My question is based on installing typescript in existing React project. It is not related to how to create typescript react!
I have cloned a repo from AWS where there is a react app. Now, I need to make an app using typescript. To install the typescript in React I have run a command "npm install --save typescript #types/node #types/react #types/react-dom #types/jest". It is creating typescript in package.json but not creating tsconfig.json file.
My other question is should index.ts file created automatically in React and if it is then how could I convert into lib/index.js within React.

Please consider the article linked in the comments of the post as a guide for migrating from JSreact to TSreact.
For a simple answer, the command below will init a tsconfig.json file
with npm as a manager.
npx tsc --init
for yarn
yarn tsc --init
(for completeness).

Related

pnpm in monorepo - how to run a command only in a specific package?

Let's say I want to install a package in a specific package in my monorepo, how do I do this from root?
in npm, you can do this with something like this:
npm install react --workspace=a
I searched the docs and I can't find a way to do this in pnpm.
It is called "filtering" in pnpm docs (see it here).
In this case, you would run:
pnpm --filter=a add react
or
pnpm -F=a add react

Angular custom npm package 'Cannot find module'

I have created a custom npm package library, I have successfully created it and published on npm and then installed the package using npm install <my-package-name>.
And now I am facing issue on importing the package.When I import it in app.module.ts file its shows:
Cannot find module 'my-module-name' or its corresponding type declarations.
I have also tried by deleting the node-modules and package-lock.json files and then npm install but sadly it's not works.

npx work only with create-react-app package

according to React JS Official docs, I have removed the create-react-app package from my system and after I try to create a new react project with npx create-react-app app-name command but it did not work for me, After I installed again create-react-app package globally now npx command work perfectly now I'm confused why npx does not work without create-react-app?

create-react-app not working ?? Any Help is Appreciated

just tried creating my first react app but surely react is not in a mood to welcome me.
Just after installing everything node and create-react-app even checking their versions to make sure they are installed.I moved on to creating the react app using npm create-react-app my-app command but it has given me this error and i am not able to resolve.
Any HELP will be appreciated.
I even tried updating the config file but Showed these errors as well.
As specified in the create-react-app github repository wiki. Please go through the detailed step by step instructions.
npx
npx create-react-app my-app
(npx is a package runner tool that comes with npm 5.2+ and higher)
npm
npm init react-app my-app
npm init is available in npm 6+
Yarn
yarn create react-app my-app
Reference Link: https://github.com/facebook/create-react-app#creating-an-app

ReactJs: How to build npm library

I am new to react. I want to build a npm reactjs library. I have a reactjs project and I want to general it as a package(library) that can be used by other project. For example, people can use "npm install" command to import my project.
Edit package name in package.json
Publish a package
npm publish --access public
ref

Categories