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!
Related
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
I tried downloading and running a Vue.js project from GitHub that was sent to me, but as soon as I tried npm run serve, I got the following error:
Syntax Error: Error: No ESLint configuration found in C:\Users\User\Desktop\movies-main\src.
I ran npm install too beforehand. I've create a couple of Vue.js projects myself and have never had this error so I'm not sure how to solve it. Could I be missing a dependency on my machine or something? I haven't used ESLint before.
Open your project folder. Then run the following command
npm install eslint -g -D
Then finish by typing :
eslint --init
Solve the problem for me.
Or use the locally installed eslint
npm init #eslint/config
I went to an issue while trying to create some build steps for Node project.
Issue:
npm install --production --prefix ./.build - Gives me an error
I tried changing the name in the package.json but I still receive the same error:
The current working drectory is important to npm.
Are you sure you're in your app folder?
Please type pwd command if you're unsure...
That error is usually produced when running npm command from a wrong folder...
The problem is, that you have the project you are working on at the moment as dependency in your project - check the package.json file. Try changing the name of the project in package.json.
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.
I installed react-native-elements through npm a while ago. This morning, I was trying to create an Overlay component from the package, but for some reason I kept getting an error that no such component existed. So, foolishly, I ran npm install react-native-elements again, and now every time I try to build I get the following error:
Unable to resolve ./social/SocialIcon" from "./C:\\Users\\L\\IdeaProjects\\FinalProject\\node_modules\\react-native-elements\\src\\index.js: The module ./social/SocialIcon could not be found"`.
I have react-native-vector-icons installed. I have no idea why this is happening.
Try install #expo/vector-icons
npm install #expo/vector-icons --save
https://github.com/react-native-training/react-native-elements/issues/620