win10 yarn cant find typescript - javascript

I have a git repo that I'm supposed to launch with the command react-scripts start. When I run this command I get this response saying typescript cant be found:
react-scripts start
It looks like you're trying to use TypeScript but do not have typescript installed.
Please install typescript by running npm install typescript.
If you are not trying to use TypeScript, please remove the tsconfig.json file from your package root (and any TypeScript files).
I have tried installing typescript in command prompt with npm i typescript, npm i -g typescript, yarn add typescript, yarn global add typescript, and "choco install typescript".
I am able to run typescript files, but still if I try to launch my program I get that error saying I dont have typescript installed.
If I just run tsc in my command prompt or powershell I get some error alerts that I have tried to solve but no luck yet:
tsc
src/App.tsx:12:5 - error TS2307: Cannot find module 'react/jsx-runtime' or its corresponding type declarations.
12 <UserAccountContext.Provider value={guestAccount}>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
13 <div className="App container">
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
...
24 </div>
~~~~~~~~~~~~
25 </UserAccountContext.Provider>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/App.tsx:13:7 - error TS2339: Property 'div' does not exist on type 'JSX.IntrinsicElements'.
13 <div className="App container">
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/App.tsx:15:9 - error TS2339: Property 'div' does not exist on type 'JSX.IntrinsicElements'.
Is there some way I can ensure typescript is installed? Ive tried running the installation commands in both powershell and command prompt.

You can just simply install in your project by using yarn add typescript #types/node #types/react #types/react-dom #types/jest or npm install --save typescript #types/node #types/react #types/react-dom #types/jest.
If you have a problem with the scripts perhaps updating them will solve it, you can try this command: npm install react-scripts#latest
For further information you can check this links: Create React App and Typescript Docs
Also you may check frameworks that have native support to TS, like Next and Gatsby

Related

How to compile typescript?

If I use tsc it doesn't work. If I don't have tsc but have typescript, it still doesn't work. What can I do?
You have to install the typescript library like this.
npm install typescript --save-dev
Then npx tsc command will work.
What you have installed is a deprecated library called tsc
Check here. So you may have to remove that first with the following command
npm uninstall tsc

Error installing dependencies with ESLint, the STDIN does not get the key

Hello I am configuring with ESLint for do this i do the following steps
npm install eslint --save-dev
npx eslint --init
But when the wizard ask about
Which style guide do you want to follow?
and select google or airbnb
this ask another question
Checking peerDependencies of eslint-config-airbnb-base#latest The
config that you've selected requires the following dependencies:
eslint-config-airbnb-base#latest eslint#^4.19.1 || ^5.3.0
eslint-plugin-import#^2.14.0 ? Would you like to install them now with
npm? (Y/n)
but the STDIN doesn't work, then I cannot continue with the configuration.
I tried to install the dependencies separately but it did not work
Any idea?
Thanks
Solved installing npm install inquirer#6.3 --save-dev first, this is a issue in: https://github.com/eslint/eslint/issues/11862

Could not find a declaration file for module 'react'

I learn Microsoft's manual about TypeScript + React + Redux.
I launched the command:
npm install -S redux react-redux #types/react-redux
But when I run the command npm run start I get the error:
Type error: Could not find a declaration file for module 'react'.
'C:/lab/my-app/node_modules/react/index.js' implicitly has an 'any'
type.
Ok, I run the command: npm i #types/react. now I get other error:
Type error: Module '"../../node_modules/#types/react-redux"' has no
exported member 'Dispatch'. TS2305
How can I fix it?
I had this problem when I initially created a React with TypeScript project, it made no sense since I had not started any work yet.
So in terminal I ran:
rm -rf node_modules/ && npm install
Then:
npm run start
And I was able to see the main landing page.
run the following:
pm install #types/react
It works for me!

npm ERR! code EPERM and errno -4048 on windows 10

I'm writing code using WebStorm. Today I tryed to install redux-form and from that moment the code it's broken. Also if the yarn install goes well I i get this error into browser on localhost
C:/Users/WebstormProjects/.....reducer.ts
(7,40): Could not find a declaration file for module 'redux-form'. 'C:/Users/WebstormProjects.....index.js' implicitly has an 'any' type.
Try `npm install #types/redux-form` if it exists or add a new declaration (.d.ts) file containing `declare module 'redux-form';`
The code have no semantic error and I also installed as the error says npm install #types/redux-form but the situation it's the same. Can someone help me??
(Posted on behalf of the question author).
I solved the problem deleting the directory with node modules and do: npm install, installing the redux-form and later installing types for this component.

Typescript command "tsc" undefined. Tried every known solution

Welcome,
I can't run Typescript all my day. I use Visual Studio Code. What I am doing is installing TS globally:
$ npm install -g typescript
Then when I check it:
$ tsc
I get that error in all cases:
bash: tsc: command not found
To that time I have tried following solutions:
Setting npm config:
$ npm config set prefix /usr/local
What I get after npm root -g is:
C:\Program Files\Git\usr\local\node_modules
Setting npm config by relative way to get (And I get it):
C:\usr\local\node_modules
Setting .bash_profile:
export PATH=/usr/local/share/npm/bin:$PATH
Setting .bashrc with PATH also...
Installing Typecript as dev dependency also don't work.
Other small solutions that I even don't remember.
Please for help. I can provide more information that you need - just say what.
Tried every known solution
Will definitely work:
Uninstall nodejs
Install nodejs (make sure you ask it to set PATH for you)
npm install typescript -g
🎊🌹

Categories