Declaration file errors for npm packages in React - reactjs

I'm using React—not with TypeScript—and I have successfully installed a few common npm packages (React and React Router, Draft.js (Facebook's rich text editor), Prism, bcrypt, etc.)
I'm trying to install two npm packages to use with Draft.js— draft-js-code and draft-js-prism—and I'm repeatedly getting this error:
Could not find a declaration file for module 'draft-js-prism'. >'/Users/username/beta/react/node_modules/draft-js-prism/lib/index.js' implicitly has an >'any' type.
Try npm install #types/draft-js-prism if it exists or add a new declaration (.d.ts) >file containing declare module 'draft-js-prism';ts(7016)
I've tried some basic stuff: uninstalling and reinstalling, installing typescript, npm rebuild... nothing. What's going on here? Again, I'm not using typescript and I've installed other npm packages in this project successfully. I've even installed other npm packages after these two that aren't causing errors.
Please help/pulling out my hair.

Related

Can't resolve 'react-motion'

I am having troubles on runnning a code online, it's the sliding image puzzle from this link: https://www.youtube.com/watch?v=_wdbhVvMOCs and here is the github from the video's description: https://github.com/danba340/react-sliding-puzzle
If I type in npm start, it shows
this error on the local host.
After running it on the VS Code, it shows
this error that says \node_modules\react-motion doesn't exist.
Whenever I try npm install --save react-motion , it shows
this error on the Visual Studio Code.
Please help me this is for my project thank you!
The reason is because the library doesn’t support react 17 yet.
Try by reinstalling your modules from scratch with the following:
rm -rf node_modules package-lock.json; npm i; npm i react-motion
If that doesn’t work, you’ll need to force the installation:
npm i react-motion —-legacy-peer-deps
If the library still have problems, you’ll then need to downgrade react to version 16 instead of 17 to make it work.
Last but not least, if you don’t want to downgrade, you can try to do the same by using yarn instead of npm

Installing Gatsby plugins breaks entire app

Whenever I install any gatsby plugins or typography files, and then attempt to run gatsby develop, I am thrown an error sying that 'react' can't be found. Example:
I create a new gatsby site using gatsby new example-site https://github.com/gatsbyjs/gatsby-starter-hello-world
I install the gatsby-plugin-sass using npm install --save node-sass gatsby-plugin-sass
I follow the instructions on the plugin page, adding the plugin to my gatsby-config.js file.
When I now attempt to run gatsby develop I receive the following errors:
ERROR
There was a problem loading the local develop command. Gatsby may not be installed. Perhaps you need to run "npm install"? Cannot find module 'react'
Error: Cannot find module 'react'
As well as a list of files that the errors are being thrown in, most of them in internal files.
Clearly I have the Gatsby-cli installed, as well as react. I'm also receiving a ton of warnings about deprecated related to core-js and optional dependencies not being installed.
In my research, I have found people saying that using yarn instead of npm solves the issue, but with Gatsby being as large of a project as it is, and with the documentation itself saying to use npm, that doesn't seem like a solution but rather a work around. Is there any other info on this that I just can't seem to find?
I reprodued your error, and after looking around I found several issues on the Gatsby GitHub repo with the same behavior.
It seems that this is a problem with npm itself, which is why the community is increasingly switching to yarn.
If you'd like to stick with npm, the solution is to clear your node_modules and package-lock.json, then reinstall your dependencies (source):
rm -rf node_modules/ package-lock.json
npm install

Node modules disappear after initializing the localy installed ESLint

In my initial react application (created by react-native init project_name). In my project folder, I install my ESLint locally by yarn add eslint --dev.
Then I initialize my configuration by ./node_modules/.bin/eslint --init (with Airbnb style guide, using React, and JSON configuration file format). The installed eslint is disappeared in ./node_modules/.bin folder.
Before initialization:
ls ./node_modules/.bin
acorn eslint jest-runtime node-pre-gyp semver
atob esparse js-yaml nopt sshpk-conv
babylon esvalidate jsesc pegjs sshpk-sign
color-support handlebars json5 rc sshpk-verify
detect-libc image-size loose-envify react-native uglifyjs
envinfo import-local-fixture metro regjsparser uuid
escodegen is-ci mime rimraf watch
esgenerate jest mkdirp sane which
After initiliazation:
ls ./node_modules/.bin
babylon esparse esvalidate jsesc loose-envify semver
What am I missing?
Platforms: macOS, react-native-cli: 2.0.1, react-native: 0.54.2
This is caused by a bug in NPM 5 where npm install will delete almost all of your dependencies. This was the relevant issue. Even though you are using yarn, eslint will use npm under the hood to install the dependencies it needs, and thus will run into the aforementioned bug.
This has very recently been fixed in npm >= 5.7.1, so you will need to upgrade npm and then reinstall all of your modules.
Personally, I'd just recreate the entire project from scratch since it doesn't seem like you've done anything yet. It would be a lot more straightforward than trying to fix things.
By upgrading, you will also be able to use react-native-cli without error as prior to v5.7.1, you were actually supposed to use NPM 4. See this bug.

VSCode AngularJS Intellisense not working

Installed typings globally
npm install -g typings.
Installed AngularJS types
typings install dt~angular --save
jsconfig.jsong file is in the root of my angular project along with typings.json and typings folder containing the angular module typings. I restarted vscode, still nothing.
What else can I check?
For JS projects, typings should be acquired automatically. Take a look at our documentation on automatic type acquisition for more info.
If automatic type acquisition is not working for some reason, try using #types instead of using typings:
npm i --save-dev #types/angular
These typings files should be automatically picked up for intellisense in VSCode.
Then if you still don't see proper intellisense, please open an issue. Include your jsconfig.json and some example code.

Installing 2 year old application

I started a project 2 years ago that I now can't seem to install into other directories.
I used to follow these steps to install my angular frontend
npm install gulp
npm install typings
npm install
typings install
gulp build
I never had to do them again and it correctly installed a typings folder from which the gulp file found all it packages, it worked and I didn't mind how.
I am now trying to install it again and it does not fill the typings folder correctly, there only appears a index.d.ts file.
I found here https://github.com/typings/typings/tree/abea10b5787e1a18634d5f37bb2fa56550c32fd1
that it should've been around version 1.0.4.
So I try to install with:
npm install typings#1.0.4
But this still does not install any typing directory.
Any direction I should look into further would be apreciated.
If you look have a package.json file for the 2 year old project (which you should) then you should find the version numbers of each dependency in there.
Putting all my files in the package.json to the specified version an not just compatible with changed the error to Syntax error parsing, I was able to fix that with removing a translate application.

Resources