I published my first package using npm. However, when I import it in Codesandbox it gives me a warning
Error when converting '/node_modules/protected-react-routes-generators/src/index.js' esmodule to commonjs: Cannot read property 'type' of null
This is my github Repo
Also when i installed it from NPM, it gives me this error
I don't know what this error is, any clue ?
Thanks!
Babel can't compile jsx extensions. Install:
npm install --save-dev #babel/preset-react
And add to your .babelrc file:
{"presets": ["#babel/preset-react"]}
I made a mistake which I published the package as a react component without build it to be a raw javascript
Related
When ever I attempt importing tosify into react:
Using the following:
import { ToastContainer, toast } from 'react-toastify'; import 'react-toastify/dist/ReactToastify.css';
I get the following error:
Failed to compile.
./node_modules/react-toastify/dist/react-toastify.esm.mjs
Can't import the named export 'cloneElement' from non EcmaScript module (only default export is available)
Not sure what solution is and have spent alot time trying to find solution but I am unable too, if anything else is needed let me know but when the tosify import not there the site works fine.
Try by changing the version to older version of toastify. Manually add this in your package.json file "react-toastify": "^8.1.0", , and then run npm i then again run npm start.
As stated in this bug report, this seems to be an issue that appears when react-toastify is used with older versions of react-scripts.
Your options are:
upgrade to the newest version of react-scripts (version 5 or above)
downgrade react-toastify to version 9.0.3, which seems to still work with older versions of react-scripts
All you need to do is this
npm i react-toastify#9.0.3
It seems to be some kind of error because of node version. Could you try to reproduce this with latest node version?
Don't forget to remove node_modules and yarn.lock | package-lock.json
I solved by updating my node version and react version,
npm install --save react#latest
npm install -g npm-check-updates
npm audit fix --force
I faced the same issue in React 18.2.0, which was fixed by:
#upgrading to the latest version of react-scripts
npm install react-scripts#5.0.1 # OR npm install --save react-scripts#latest
#if you encounter errors after upgrading.
rm -r node_modules
npm install
I had the same problem, I have tried to update my yarn , and react versions , but the problem was still there.
the best way is to downgrade toastify version to 8.0.0, and it will work.
use this command:
npm i react-toastify#8.0.0
or: if you are using yarn
yarn add react-toastify#8.0.0
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.
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
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
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!