>> Error: Cannot find module 'mongodb/lib/mongodb/connection/read_preference'
I am running a grunt server that can't find mongodb connection read_preference. As a result, my DOM was broken.
It sounds like it may be an issue with you package.json. Perhaps missing dependencies?
I have also seen this problem with mongoskin. If you are using that, try removing and reinstalling it.
After running npm install, you get node_modules directory populated with all dependencies. Here is what I got for default MEAN distribution:
$ find . -name "read_preference*" -print
./node_modules/connect-mongo/node_modules/mongodb/lib/mongodb/connection/read_preference.js
./node_modules/mongoose/node_modules/mongodb/lib/mongodb/connection/read_preference.js
And in package.json you can see following related entries:
"connect-mongo": "~0.4.1",
"mongoose": "~3.8.8",
Which are the modules you need to have to resolve that dependency.
Delete the node_modules directory and run npm install.
Related
I'm new to working with Sanity, and just set up a project. Everything is working fine, however, in Visual Studio Code, I keep getting a parsing error that won't disappear, and I'm wondering how I can fix it.
Parsing error: Cannot find module '#babel/preset-env'
I've tried deleting the node_modules and re-running sanity install, I've also tried using npm install to install #babel/core and #babel/preset-env. Nothing seems to have fixed the problem so far.
Any suggestions? I want to start using Sanity with my team at work, but having this error is really quite annoying (as everything is underlined in red).
I was having a similar issue. For me, the issue was related to the way VS Code deals with a project containing multiple ESLint working directories (common in monorepos).
For example
Project
|--- /web
|--- /studio
In my project root, edit (or create) ./.vscode/settings.json to include my ESLint projects. NB: these settings only apply to your current workspace.
"eslint.workingDirectories": ["./web", "./studio"]
Hope that helps :-)
Method 1:
Create a file called .babelrc in your root directory and add this code
{
"presets": ["next/babel"],
"plugins": []
}
And in .eslintrc replace the existing code with
{
"extends": ["next/babel"]
}
Method 2:
You need to install npm with this command:
npm install --save-dev #babel/core #babel/preset-env
or
npm install --save-dev #babel/core
I hope this will solve your problem.
I would like to ask if how should I fix this issue because I am already stuck and confused about this part. I already installed rollup globally using this command
npm install --global rollup
However when I tried to run the 'rollup' command then I should expect the rollup information or something will show in my CLI? but my CLI shows
'rollup' is not recognized as an internal or external command,
operable program or batch file.
What I have done so far is.
Updated the NPM
Reinstall the rollup globally.
I already read some documentation but the issue is still showing.https://github.com/Esri/ago-assistant/issues/176
Please enlighten me.
Thank you
What I just have done just to run the script globally.
I just added these scripts in my package.json to run the rollup using NPM.
"scripts": {
"rollup": "rollup"
is this okay?
Try restarting your terminal
Try locating where the Rollup binary is installed
%AppData%\npm\node_modules or %AppData%\roaming\npm\node_modules
and run it manually like
%AppData%\npm\node_modules\rollup\bin\rollup.exe
npm install
fixed this issue for me
I have a next.js project and I keep getting:
error - ./node_modules/jspdf/dist/jspdf.es.min.js:458:25
Module not found: Can't resolve 'canvg'
I'm not sure why because I'm not including either jspdf or canvg.
Not sure what's causing it. Any help would be appreciated. I'm using material-ui if that matters.
It seems dependency error means that particular Module is missing when it's running.
Run npm ls or yarn list will print to stdout all the versions of packages that are installed, as well as their dependencies, in a tree-structure. Then search for that particulate packages are listed or not.
Run npm ls jspdf or yarn list jspdf then you can see its list of dependencies in tree-structure.
Please check your node version is updated or not ? If not then update first.
Quick & Dirty way: delete package.lock or yarn.lock file and delete .node_modules folders And Then run npm install or yarn to install again.
Look at console while you installing and make sure there are no error in the installing process. If you saw error you better look that massages also.
I am facing below issue and unable to figure out the root cause.
Error: Cannot find module 'loopback'
Below are the dependencies I have in my package.json
"loopback": "^3.19.0",
"loopback-boot": "^2.6.5",
"loopback-component-explorer": "^6.0.0",
"loopback-connector-postgresql": "^2.9.0"
First I did npm i and then node .
But it throws an error Cannot find module 'loopback'
Don't understand why this is behaving differently. Please suggest
Edit: My all modules are found under
> node_modules
> .staging
> //loopback modules and other modules are placed under .staging but not sure why.
The fact that your dependencies are inside the staging directory and not the main node_modules directory imply that something went wrong with the download/installation process and your dependencies are not installed properly. And hence you get the 'Could not find module' error.
Try the following steps -
Delete package-lock.json
Delete Node Modules folder
Do a npm install to install packages listed in package.json
Once the installation is complete, all your node dependencies should be inside your node_modules folder.
It might also be worth checking to see if you have more than one node version on your machine. That could cause similar problems as well.
use
npm config set user 0
npm config set unsafe-perm true
npm install -g loopback-cli
npm install
https://loopback.io/doc/en/lb3/
I am new to react-native and have found an error that makes absolutely no sense to me.
I am trying to include a calendar library: https://github.com/wix/react-native-calendars
I have included the dependency for that library in my package.json file and run npm install
The project was running fine and as expected. I have simply added one line of code to the project:
import { Calendar, CalendarList, Agenda } from 'react-native-calendars';
Nothing else. However now I am getting a red error message when the app loads on device and this is what my console is saying:
error: bundling failed: Error: While trying to resolve module xdate
from file
/Users/Alex/Documents/workspace/mobile/node_modules/react-native-calendars/src/index.js,
the package
/Users/Alex/Documents/workspace/mobile/node_modules/xdate/package.json
was successfully found. However, this package itself specifies a
main module field that could not be resolved
(/Users/Alex/Documents/workspace/mobile/node_modules/xdate/src/xdate.js.
Indeed, none of these files exist:
*
/Users/Alex/Documents/workspace/mobile/node_modules/xdate/src/xdate.js(.native||.ios.js|.native.js|.js|.ios.json|.native.json|.json)
*
/Users/Alex/Documents/workspace/mobile/node_modules/xdate/src/xdate.js/index(.native||.ios.js|.native.js|.js|.ios.json|.native.json|.json)
at ResolutionRequest.resolveDependency (/Users/Alex/Documents/workspace/mobile/node_modules/metro/src/node-haste/DependencyGraph/ResolutionRequest.js:103:15)
at DependencyGraph.resolveDependency (/Users/Alex/Documents/workspace/mobile/node_modules/metro/src/node-haste/DependencyGraph.js:272:4579)
at dependencies.map.relativePath (/Users/Alex/Documents/workspace/mobile/node_modules/metro/src/DeltaBundler/traverseDependencies.js:376:19)
at Array.map ()
at resolveDependencies (/Users/Alex/Documents/workspace/mobile/node_modules/metro/src/DeltaBundler/traverseDependencies.js:374:16)
at /Users/Alex/Documents/workspace/mobile/node_modules/metro/src/DeltaBundler/traverseDependencies.js:212:33
at Generator.next ()
at step (/Users/Alex/Documents/workspace/mobile/node_modules/metro/src/DeltaBundler/traverseDependencies.js:297:313)
at /Users/Alex/Documents/workspace/mobile/node_modules/metro/src/DeltaBundler/traverseDependencies.js:297:473
at
However I have checked in the directory and in fact /Users/Alex/Documents/workspace/mobile/node_modules/xdate/src/xdate.js does exist. However I do not see any of this part: (.native||.ios.js|.native.js|.js|.ios.json|.native.json|.json)`
As to how /Users/Alex/Documents/workspace/mobile/node_modules/xdate/src/xdate.js/index can exist, that doesn't make sense because xdate.js is not a directory.
Any help?
It Usually happens if you try to install a module while your packager is open.
Try to delete node_modules folder and close the packager.
Then reinstall everything by npm install in your project directory.
First close your JavaScript bundler (Metro bundler in my case) and restart the application. This will create fresh dependency graph. This should solve the issue.
Just restart the bundler - no need to delete the Node Modules folder
I came across this issue when adding and using react-native-elements when using VS Code and Android Studio emulator on Linux Mint
In VS Code I had a terminal running Expo with Metro Bundler via 'npm start' command. After installing the react-native-elements in the folder (using 'npm install --save react-native-elements') and adding the import into the .js file I got the "However, this package itself specifies a main module field that could not be resolved" error.
In my case, this just involved a ^C in the terminal session to stop the Metro bundler and then running 'npm start' again. There was no need to delete the node modules folder at all.
If you're still getting the error even after deleting the ./node_modules folder and running npm install again, try doing the install with the --update-binary flag, i.e npm install --update-binary. This should clear out and rebuild any previously built packages on your machine.
Please don't delete the node modules folder.
The bundler has least to deal with node modules folder.
Instead close all the terminals. If using VS-code close that also.
Close all the local host server ports and if possible restart the system.
This might solve the issue.
If anyone have same issue, and remove node_module not working. Then you can try remove all node_module, package lock and using yarn to install node_module instead npm. Hope this help
None of the solutions above helped me except for restarting my MacBook. Wasted 30 minutes trying to fix this issue as I couldn't believe restarting my computer could be a solution.