I installed firebase-admin in my React project, and suddenly I am getting a ton (116 to be exact) of "Module Not Found Errors" when loading the page - 'stream', 'util', 'assert', 'url', 'crypto' and the list goes on and on. Not sure what happened. I tried removing firebase-admin from the package.json file, but that did not fix the errors.
Any suggestions? The app was working fine until I installed firebase-admin.
Try this and see if it fix your problem:
Remove your node_modules folder (rm -rf node_modules)
npm cache clean -f
npm install
npm install firebase-admin
The errors seem to stem from the following import line:
import { firestore } from 'firebase-admin';
Related
I want to add Linking images feature to my React app that uses '
#ckeditor/ckeditor5-build-decoupled-document
code:
import React from 'react'
import { CKEditor } from "#ckeditor/ckeditor5-react";
import * as DecoupledEditor from "#ckeditor/ckeditor5-build-decoupled-document";
but when I import:
import linkimage from '#ckeditor/ckeditor5-link/src/linkimage';
I get an error:
Uncaught CKEditorError: ckeditor-duplicated-modules
more info about images linking
How can I add linking images?
I assume you have done:
npm install --save #ckeditor/ckeditor5-image
and enabled the plugin with:
import LinkImage from '#ckeditor/ckeditor5-link/src/linkimage';
then add this into your editor config:
image: {
toolbar: [
'imageStyle:block',
'imageStyle:side',
'|',
'toggleImageCaption',
'imageTextAlternative',
'|',
'linkImage' <---- here
]
}
even if the error still persist, try the error code docs for it here
Packages were duplicated in node_modules
In some situations, especially when calling npm install multiple times, it may happen that npm will not correctly "deduplicate" packages.
Normally, npm deduplicates all packages so, for example, #ckeditor/ckeditor5-core is installed only once in node_modules/. However, it is known to fail to do so from time to time.
We recommend checking if any of the steps listed below help:
rm -rf node_modules && npm install to make sure you have a clean node_modules/ directory. This step is known to help in most cases.
If you use yarn.lock or package-lock.json, remove it before npm install.
Check whether all CKEditor 5 packages are up to date and reinstall them if you changed anything (rm -rf node_modules && npm install).
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
I got a sudden error that the module 'fs' is unable to resolve. But I have not used this module nor changed anything. My App suddenly returns this error while starting.
error: bundling failed: Error: Unable to resolve module fs from
/Path/to/Project/node_modules/handlebars/lib/index.js: Module fs
does not exist in the Haste module map
This might be related to
https://github.com/facebook/react-native/issues/4968 To resolve try
the following:
Clear watchman watches: watchman watch-del-all.
Delete the node_modules folder: rm -rf node_modules && npm install.
Reset Metro Bundler cache: rm -rf /tmp/metro-bundler-cache-* or npm start -- --reset-cache.
Remove haste cache: rm -rf /tmp/haste-map-react-native-packager-*.
I already tried the four steps to resolve, several times but nothing helped.
Any ideas what could be wrong?
For me, the issue was that VSCode had inserted some imports at the top of one of my js files. Very odd.
These were the lines:
import { tsConstructorType } from '#babel/types';
import { logger } from 'handlebars';
One of my node modules is depending on react-native-dotenv, but its code was using old import like import {} from 'react-native-dotenv'.
But latest version of dotenv is using import {} from '#env'.
Fixing this import in the module resolved the problem.
Usually you can fix these surprise errors by clearing your cache. Run $ expo start --clear.
I had this error because I was trying to use dotenv when I should have been using one of these react-native specific packages. Check that all your installed packages are compatible with react native.
I had exactly this issue. Visual Studio Code users, autocomplete will sometimes auto-import modules you have no need for at the top of your file without you noticing. Running git diff revealed the following lines I had no memory of every writing at the top of a file I'd worked on:
+import { clearConfigCache } from 'prettier';
+import { createIconSetFromFontello } from 'react-native-vector-icons';
How to avoid:
Run git diff and read every single line that follows. The offenders will usually turn up.
If you are importing a module (a functional/class component from another file) in expo react native, be sure to mention "./" in the assets array of the rnpm object in the package.json file like this:
"rnpm": {
"assets": [
"./"
]
}
Do not try to install "fs" module separately, it would give more errors.
my auto-suggestion accidentally imported this in my file which caused the same problem.
import { status } from "express/lib/response";
I removed and it worked.
try to find something in import that should not be there like from backend imports.
In my React app, which was built using create-react-app, I'm getting the error:
Module not found: Can't resolve 'react-icons/io' in '/usr/src/app/src/components/analytics_components'.
The app has been working fine for a while but I just rebuilt it using Docker Compose and now it's not.
It seems like it's looking in the wrong directory, src instead of node_modules.
react-icons is definitely installed, npm list react-icons returns its version number.
I can see the io folder in node_modules/react-icons
The import statement:
import { IoMdList } from "react-icons/io";
When I change the import to explicitly point to the node_modules directory, it works, but I didn't need to do this before nor do I need to for any other packages, which are still all working correctly:
import { IoMdList } from "../../../node_modules/react-icons/io";
I just reinstall the command npm install react-icons and then it works.
Again you can install npm if you already installed that doesn't matter you can re-install your npm again without deleting current node module. it works for me. command: npm install
you can try delete your node module folder and run cmd:npm install or yarn install it may solve your problem
I created a native module and created another project to test it locally.
Here are my steps:
cd <Testing project>
npm install ../<Module project>
react-native link <module name>
react-native run-android
Then I got following error:
error: bundling failed: Error: Unable to resolve module `react-native-helloworld` from `G:\Test\App.js`: Module `react-native-helloworld` does not exist in the Haste module map
This might be related to https://github.com/facebook/react-native/issues/4968
To resolve try the following:
1. Clear watchman watches: `watchman watch-del-all`.
2. Delete the `node_modules` folder: `rm -rf node_modules && npm install`.
3. Reset Metro Bundler cache: `rm -rf /tmp/metro-bundler-cache-*` or `npm start -- --reset-cache`.
4. Remove haste cache: `rm -rf /tmp/haste-map-react-native-packager-*`.
I've searched StackOverflow for the issue, but there's no workable solution. The suggested solution 'clear the cache and reset everything' cannot work.
However, the module can work if I publish it to https://www.npmjs.com/ and then install it via npm install <module name>.
The only difference is the installing way.
I got a similar error complaining about how it could not find 'path' from where ever it was looking for. In the end I figured out that the issue was completely unrelated.The following auto import was accidentally added to my code (probably when I was creating a style using 'textTransform')
import { transform } from "#babel/core";
Once I noticed that and removed it, the project was buildable. It might help to check recent changes in your code to see if something similar got added.
Chances are that you're accidentaly symlinking your library inside node_modules when you use npm, instead of using npm you can use yarn
yarn add file:../<module_project>