I want to import this npm package from npm but it returns error
I have init new project and done this
npm install #google/maps --save
var googleMapsClient = require('#google/maps')
Error is this
this is error log
error: bundling: UnableToResolveError: Unable to resolve module `url` from `/Users/barron9/Downloads/meteor/node_modules/#google/maps/lib/internal/make-api-call.js`: Module does not exist in the module map or in these directories:
/Users/barron9/Downloads/meteor/node_modules
, /Users/barron9/Downloads/node_modules
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 packager cache: `rm -fr $TMPDIR/react-*` or `npm start -- --reset-cache`.
at ResolutionRequest._resolveNodeDependency (/Users/barron9/Downloads/meteor/node_modules/react-native/packager/src/node-haste/DependencyGraph/ResolutionRequest.js:394:11)
at ResolutionRequest.resolveDependency (/Users/barron9/Downloads/meteor/node_modules/react-native/packager/src/node-haste/DependencyGraph/ResolutionRequest.js:141:29)
at dependencyNames.map.name (/Users/barron9/Downloads/meteor/node_modules/react-native/packager/src/node-haste/DependencyGraph/ResolutionRequest.js:145:59)
at Array.map (native)
at ResolutionRequest.resolveModuleDependencies (/Users/barron9/Downloads/meteor/node_modules/react-native/packager/src/node-haste/DependencyGraph/ResolutionRequest.js:145:42)
at Promise.resolve.then (/Users/barron9/Downloads/meteor/node_modules/react-native/packager/src/node-haste/DependencyGraph/ResolutionRequest.js:169:21)
at process._tickCallback (internal/process/next_tick.js:109:7)
Bundling `index.android.js` 94.3% (405/417), failed.
error: bundling: UnableToResolveError: Unable to resolve module `url` from `/Users/barron9/Downloads/meteor/node_modules/#google/maps/lib/internal/make-api-call.js`: Module does not exist in the module map or in these directories:
/Users/barron9/Downloads/meteor/node_modules
, /Users/barron9/Downloads/node_modules
Please try:
import googleMapsClient from '#google/maps';
Otherwise, that package does not target React-Native, I think.
Would you consider using the correct package for react-native, which works well in my react-native project:
https://github.com/airbnb/react-native-maps
Related
When running yarn ios the following error is shown
Missing package "metro-config" in the project. This usually means react-native is not installed. Please verify that dependencies in package.json include "react-native" and run yarn or npm install.
Error: Missing package "metro-config" in the project. This usually means react-native is not installed. Please verify that dependencies in package.json include "react-native" and run yarn or npm install.
at importMetroConfigFromProject (/usr/local/lib/node_modules/expo-cli/node_modules/#expo/metro-config/src/ExpoMetroConfig.ts:244:11)
at getDefaultConfig (/usr/local/lib/node_modules/expo-cli/node_modules/#expo/metro-config/src/ExpoMetroConfig.ts:70:23)
at Object.loadAsync (/usr/local/lib/node_modules/expo-cli/node_modules/#expo/metro-config/src/ExpoMetroConfig.ts:230:23)
at runMetroDevServerAsync (/usr/local/lib/node_modules/expo-cli/node_modules/#expo/dev-server/src/MetroDevServer.ts:67:45)
at startDevServerAsync (/usr/local/lib/node_modules/expo-cli/node_modules/xdl/src/start/startDevServerAsync.ts:62:55)
at startAsync (/usr/local/lib/node_modules/expo-cli/node_modules/xdl/src/start/startAsync.ts:74:41)
And after i was able to get the package i ran yarn ios again and i got this error:
metro-config tried to access metro-transform-worker, but it isn't declared in its dependencies; this makes the require call ambiguous and unsound.
Required package: metro-transform-worker
Required by: metro-config#npm:0.66.2 (via /Users/tolas/uber-eats-clone/.yarn/cache/metro-config-npm-0.66.2-e011950457-9ea7732677.zip/node_modules/metro-config/src/defaults/)
Require stack:
/Users/tolas/uber-eats-clone/.yarn/cache/metro-config-npm-0.66.2-e011950457-9ea7732677.zip/node_modules/metro-config/src/defaults/index.js
/Users/tolas/uber-eats-clone/.yarn/cache/metro-config-npm-0.66.2-e011950457-9ea7732677.zip/node_modules/metro-config/src/index.js
/usr/local/lib/node_modules/expo-cli/node_modules/#expo/metro-config/build/ExpoMetroConfig.js
/usr/local/lib/node_modules/expo-cli/build/exp.js
/usr/local/lib/node_modules/expo-cli/bin/expo.js
Error: metro-config tried to access metro-transform-worker, but it isn't declared in its dependencies; this makes the require call ambiguous and unsound.
Required package: metro-transform-worker
Required by: metro-config#npm:0.66.2 (via /Users/tolas/uber-eats-clone/.yarn/cache/metro-config-npm-0.66.2-e011950457-9ea7732677.zip/node_modules/metro-config/src/defaults/)
Require stack:
/Users/tolas/uber-eats-clone/.yarn/cache/metro-config-npm-0.66.2-e011950457-9ea7732677.zip/node_modules/metro-config/src/defaults/index.js
/Users/tolas/uber-eats-clone/.yarn/cache/metro-config-npm-0.66.2-e011950457-9ea7732677.zip/node_modules/metro-config/src/index.js
/usr/local/lib/node_modules/expo-cli/node_modules/#expo/metro-config/build/ExpoMetroConfig.js
/usr/local/lib/node_modules/expo-cli/build/exp.js
/usr/local/lib/node_modules/expo-cli/bin/expo.js
at Function.external_module_.Module._resolveFilename (/Users/tolas/uber-eats-clone/.pnp.cjs:22011:55)
at Function.resolve (internal/modules/cjs/helpers.js:98:19)
at AsyncFunction.getDefaultValues (/Users/tolas/uber-eats-clone/.yarn/cache/metro-config-npm-0.66.2-e011950457-9ea7732677.zip/node_modules/metro-config/src/defaults/index.js:140:28)
at getDefaultConfig (/usr/local/lib/node_modules/expo-cli/node_modules/#expo/metro-config/src/ExpoMetroConfig.ts:163:36)
at Object.loadAsync (/usr/local/lib/node_modules/expo-cli/node_modules/#expo/metro-config/src/ExpoMetroConfig.ts:230:23)
at runMetroDevServerAsync (/usr/local/lib/node_modules/expo-cli/node_modules/#expo/dev-server/src/MetroDevServer.ts:67:45)
at startDevServerAsync (/usr/local/lib/node_modules/expo-cli/node_modules/xdl/src/start/startDevServerAsync.ts:62:55)
at startAsync (/usr/local/lib/node_modules/expo-cli/node_modules/xdl/src/start/startAsync.ts:74:41)
I am getting a wried error when I updated to xCode10. The error said that
error: bundling failed: Error: Unable to resolve module `SegmentedControlIOS` from `/node_modules/react-native/Libraries/react-native/react-native-implementation.js`: Module does not exist in the 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 am using below version of react ana babel:
"babel-preset-react-native": "4.0.0",
"react-native": "0.54.0",
I tried to reinstall the node module. But it didn't work.
Let me know if anyone have the same issue and able to sort it out.
Thanks,
Reset caches
as usual
it works everytime like a charm.
Were you able to get this to work? If not, try starting the metro bundler on a separate terminal first (npm start on your project). This sounds like what I was getting. If you try to do npm start ios without running the metro bundler first, the working directory is set in node_modules which is why it won't find any of your files.
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>
I am trying to use a package from a relative path and I have done npm install ../../ExamplePackage and react-native install ../../ExamplePackage. These packages are relative by multiple levels and not just one.
I am getting the following errors
error: bundling failed: Error: Unable to resolve module `ExamplePackage` from `/Users/vikasagr/workspace/test/ReactNative/MyPackage/src/index.js`: Module `ExamplePackage` 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-*`.
at ModuleResolver.resolveDependency (/Users/vikasagr/workspace/test/ReactNative/MyPackage/node_modules/metro/src/node-haste/DependencyGraph/ModuleResolution.js:161:1460)
at ResolutionRequest.resolveDependency (/Users/vikasagr/workspace/test/ReactNative/MyPackage/node_modules/metro/src/node-haste/DependencyGraph/ResolutionRequest.js:91:16)
at DependencyGraph.resolveDependency (/Users/vikasagr/workspace/test/ReactNative/MyPackage/node_modules/metro/src/node-haste/DependencyGraph.js:272:4579)
at dependencies.map.relativePath (/Users/vikasagr/workspace/test/ReactNative/MyPackage/node_modules/metro/src/DeltaBundler/traverseDependencies.js:376:19)
at Array.map (<anonymous>)
at resolveDependencies (/Users/vikasagr/workspace/test/ReactNative/MyPackage/node_modules/metro/src/DeltaBundler/traverseDependencies.js:374:16)
at /Users/vikasagr/workspace/test/ReactNative/MyPackage/node_modules/metro/src/DeltaBundler/traverseDependencies.js:212:33
at Generator.next (<anonymous>)
at step (/Users/vikasagr/workspace/test/ReactNative/MyPackage/node_modules/metro/src/DeltaBundler/traverseDependencies.js:297:313)
at /Users/vikasagr/workspace/test/ReactNative/MyPackage/node_modules/metro/src/DeltaBundler/traverseDependencies.js:297:473
I tried all the steps but nothing worked. I also tried haul but that wasn't also working for me.
Symlinks were probably causing your problem. npm install with a local path installs libraries in node_modules with a symlink pointing to the local path of the package. Unfortunately this causes an issue with the react native metro bundler (" does not exist in the Haste module map").
I had the same issue with npm install. react-native install works for me, and that does not create symlinks.
Using wml is another good approach. It replicates the behavior of a symlink by automatically copying changes between your local library and its installed copy in node_modules.
See https://github.com/facebook/react-native/issues/23327 for a similar issue.
You can try WML.
https://www.npmjs.com/package/wml
What it does:
replaces npm link with something that actually works!
It worked for me !
Cheers
i'm trying to use this project
https://github.com/FaridSafi/react-native-gifted-listview
I'll write down the order processing.
download the project.zip & unzipping
in terminal, i used this command [npm install]
and this [react-native run-android] & [react-native run-ios]
but i was failed to build this project.
open-ui-iMac:react-native-gifted-listview-master openobject$ react-native run-android
Android project not found. Maybe run react-native android first?
open-ui-iMac:react-native-gifted-listview-master openobject$ react-native run-ios
/Users/openobject/practice/react-native-gifted-listview-master/node_modules/promise/lib/done.js:10
throw err;
^
Error: ENOENT: no such file or directory, uv_chdir
at Error (native)
at process.chdir (/Users/openobject/practice/react-native-gifted-listview-master/node_modules/graceful-fs/polyfills.js:18:9)
at _runIOS (node_modules/react-native/local-cli/runIOS/runIOS.js:50:11)
at node_modules/react-native/local-cli/runIOS/runIOS.js:24:5
at tryCallTwo (/Users/openobject/practice/react-native-gifted-listview-master/node_modules/promise/lib/core.js:45:5)
at doResolve (/Users/openobject/practice/react-native-gifted-listview-master/node_modules/promise/lib/core.js:200:13)
at new Promise (/Users/openobject/practice/react-native-gifted-listview-master/node_modules/promise/lib/core.js:66:3)
at Array.runIOS (node_modules/react-native/local-cli/runIOS/runIOS.js:23:10)
at Object.run (node_modules/react-native/local-cli/cliEntry.js:95:3)
at Object.<anonymous> (/usr/local/lib/node_modules/react-native-cli/index.js:88:7)
i found a few solution of this.
they say "use this command"
rm -rf node_modules
rm -fr $TMPDIR/react-*
watchman watch-del-all
npm install --save react-native#latest
but it couldn't solve this problem
how i can solve this problem?
You're trying to use a 3rd party React Native Component on your project. The right way to install and use the Component is as follow:
Get inside your react-native project: cd yourProject
On your terminal run the following code: npm install react-native-gifted-listview --save. This is the way to install Components. npm install component-name --save
Import the installed component inside your page where you want to use: import GiftedListView from 'react-native-gifted-listview';
Now you can use the component:
<GiftedListView
rowView={this._renderRowView}
onFetch={this._onFetch}
firstLoader={true}
pagination={true}
refreshable={true}
withSections={false}
refreshableTintColor="blue"
/>