Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

node Error: Cannot find module 'react-native-activity-view' #51

Open
ataillefer opened this issue Jul 6, 2016 · 1 comment
Open

node Error: Cannot find module 'react-native-activity-view' #51

ataillefer opened this issue Jul 6, 2016 · 1 comment

Comments

@ataillefer
Copy link

I've installed react-native-activity-view in my project with npm i --save react-native-activity-view then when trying to resolve the module with node I get:

~/sources/nuxeo-mobile$ node -e "require.resolve('react-native-activity-view')"
module.js:442
    throw err;
    ^
Error: Cannot find module 'react-native-activity-view'
    at Function.Module._resolveFilename (module.js:440:15)
    at Function.resolve (internal/module.js:27:19)
    at [eval]:1:9
    at Object.exports.runInThisContext (vm.js:54:17)
    at Object.<anonymous> ([eval]-wrapper:6:22)
    at Module._compile (module.js:541:32)
    at node.js:311:29
    at _combinedTickCallback (internal/process/next_tick.js:67:7)
    at process._tickCallback (internal/process/next_tick.js:98:9)

I actually first noticed this using eslint, but in fact the issue occurs at the node level:

~/sources/nuxeo-mobile$ npm run lint

> nuxeo-mobile@1.1.0 lint /Users/ataillefer/sources/nuxeo-mobile
> node node_modules/eslint/bin/eslint.js src/

/Users/ataillefer/sources/nuxeo-mobile/src/Root.js
  4:26  error  Unable to resolve path to module 'react-native-activity-view'  import/no-unresolved

with import ActivityView from 'react-native-activity-view'; at the top of Root.js.

This happens because node uses the "main" element of package.json: ActivityView to try to find the react-native-activity-view/ActivityView file which doesn't exist.

Usually "main" references an index.js file, that might be a solution if you can manage the iOS vs unsupported Android issue.

Setting "main": "ActivityView.ios.js" in package.json is a temporary workaround.

On our side we used the following workaround in .eslintrc:

'rules': {
  ...
  'import/no-unresolved': [2, { ignore: ['react-native-activity-view'] }],
},

Thanks!

@fantattitude
Copy link

It also breaks with flow.
If you use the provided module name ActivityView, flow won't complain but you'll experience a runtime error Module not found.
If you use the package name react-native-activity-view, flow will complain it can't find the module but at runtime everything will be fine…

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants