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

Naming collision detected #3558

Closed
chenchen1008 opened this issue Oct 21, 2015 · 46 comments
Closed

Naming collision detected #3558

chenchen1008 opened this issue Oct 21, 2015 · 46 comments
Labels
Resolution: Locked This issue was locked by the bot.

Comments

@chenchen1008
Copy link

when I execute ./packager/packager.sh, I see the error below!

Error building DepdendencyGraph:
Error: Naming collision detected: /Users/guo/Desktop/react-native/node_modules/react-tools/src/shared/vendor/core/dom/isTextNode.js collides with /Users/guo/Desktop/react-native/AwesomeProject/node_modules/react-native/node_modules/react-tools/src/shared/vendor/core/dom/isTextNode.js
at HasteMap._updateHasteMap (/Users/guo/Desktop/react-native/packager/react-packager/src/DependencyResolver/DependencyGraph/HasteMap.js:123:13)
at /Users/guo/Desktop/react-native/packager/react-packager/src/DependencyResolver/DependencyGraph/HasteMap.js:95:28
at tryCallOne (/Users/guo/Desktop/react-native/node_modules/promise/lib/core.js:37:12)
at /Users/guo/Desktop/react-native/node_modules/promise/lib/core.js:103:15
at flush (/Users/guo/Desktop/react-native/node_modules/promise/node_modules/asap/raw.js:50:29)
at doNTCallback0 (node.js:417:9)
at process._tickCallback (node.js:346:13)

@chirag04
Copy link
Contributor

@foghina @martinbigio I got the same error.

Some observations:

  1. react-native init projectName and then npm start. npm start if broken however react-native start works.
    err:
    sh: node_modules/react-native/packager/packager.sh: No such file or directory

  2. name collision detected error after doing react-native start.

I took master branch for generating the new project(changed the cli for this).

@corymsmith
Copy link

I'm getting similar error but its erroring out on react-tools, any ideas?

Error building DepdendencyGraph:
 Error: Naming collision detected: /Users/corysmith/Apps/indieshuffle/node_modules/react-native/node_modules/react-tools/package.json collides with /Users/corysmith/Apps/indieshuffle/node_modules/react-native/packager/package.json
    at HasteMap._updateHasteMap (/Users/corysmith/Apps/indieshuffle/node_modules/react-native/packager/react-packager/src/DependencyResolver/DependencyGraph/HasteMap.js:127:13)
    at /Users/corysmith/Apps/indieshuffle/node_modules/react-native/packager/react-packager/src/DependencyResolver/DependencyGraph/HasteMap.js:104:32
    at tryCallOne (/Users/corysmith/Apps/indieshuffle/node_modules/react-native/node_modules/promise/lib/core.js:37:12)
    at /Users/corysmith/Apps/indieshuffle/node_modules/react-native/node_modules/promise/lib/core.js:103:15
    at flush (/Users/corysmith/Apps/indieshuffle/node_modules/react-native/node_modules/promise/node_modules/asap/raw.js:50:29)
    at doNTCallback0 (node.js:407:9)
    at process._tickCallback (node.js:336:13)

@abezhinaru
Copy link

I'm getting similar error too after adding react-native-router

Error building DepdendencyGraph:
Error: Naming collision detected: /Users/andrej/projects/test/testProject/node_modules/react-native-router/node_modules/react-native/Libraries/Promise.js collides with /Users/andrej/projects/test/testProject/node_modules/react-native/Libraries/Promise.js
at HasteMap._updateHasteMap (/Users/andrej/projects/test/testProject/node_modules/react-native/packager/react-packager/src/DependencyResolver/DependencyGraph/HasteMap.js:123:13)
at /Users/andrej/projects/test/testProject/node_modules/react-native/packager/react-packager/src/DependencyResolver/DependencyGraph/HasteMap.js:95:28
at tryCallOne (/Users/andrej/projects/test/testProject/node_modules/react-native/node_modules/promise/lib/core.js:37:12)
at /Users/andrej/projects/test/testProject/node_modules/react-native/node_modules/promise/lib/core.js:103:15
at flush (/Users/andrej/projects/test/testProject/node_modules/react-native/node_modules/promise/node_modules/asap/raw.js:50:29)
at doNTCallback0 (node.js:407:9)
at process._tickCallback (node.js:336:13)

@mountainfirefly
Copy link

If your are stuck up here
So have a solution for this but not forever
you can delete you react-native folder from node_module/react-native-router/node_module/react-native
and you can use react-native from node_module/react-native

@martinbigio
Copy link
Contributor

I fixed a similar issue to the duplicated module one on dee96fb. In regards the packager.sh, that one should have been fixed on 32aeeea.

Please reopen if any of this still repro :)

cc @mkonicek in case you've seen the naming colision mentioned on the task

@martinbigio
Copy link
Contributor

This Promise issue looks legimit, sorry for closing. @mkonicek we don't have a strategy for dealing with this inside the packager, it just doesn't support having the same haste module defined twice. Fortunately, the new CLI brings the getBlacklistedRE function to the user on rn-cli.config.js so people should be able to blacklist the ones they want to get rid. Not sure if we can do anything in the mean time.

@ide
Copy link
Contributor

ide commented Oct 22, 2015

@martinbigio I have an idea for how to handle duplicate Haste modules by scoping them. I don't have the bandwidth to build it myself but will describe my vision for it in a new issue.

@skevy
Copy link
Contributor

skevy commented Oct 22, 2015

@ide, I think part of this will be solved by the issue we were just chatting about, which is that haste modules outside of react-native, react-tools, and currently, due to AsyncStorage, parse, shouldn't be used at all. Duplicate Haste module scoping would be cool, but I think fixing this other issue (which I plan to do ASAP) will solve most cases.

@ide
Copy link
Contributor

ide commented Oct 23, 2015

@skevy so just to be clear -- you want to fix deep dependencies so that we don't run javascript for Node on a platform.. that's not Node?

@skevy
Copy link
Contributor

skevy commented Oct 23, 2015

Wait, what? I don't think I said that. I'm confused by your response.

@skevy
Copy link
Contributor

skevy commented Oct 23, 2015

All I was saying was that the issue described here would be resolved by @providesModule not being used by the packager for packages outside of the FB ecosystem.

@ide
Copy link
Contributor

ide commented Oct 23, 2015

Oh i see. I thought you were referring to honoring the "browser" entry in the JSON.

@skevy
Copy link
Contributor

skevy commented Oct 23, 2015

No no...we should have the 'react-native' directive.

@mangogogos
Copy link
Contributor

What things should I know before adding to the blacklist file? as it is Im getting

Error building DepdendencyGraph:
Error: Naming collision detected:
.../main_application/node_modules/react-native/node_modules/react-tools/src/shared/vendor/core/warning.js collides with .../main_application/node_modules/react-native/node_modules/react-tools/docs/js/react.js
at HasteMap._updateHasteMap (.../main_application/node_modules/react-native/packager/react-packager/src/DependencyResolver/DependencyGraph/HasteMap.js:123:13)
at .../main_application/node_modules/react-native/packager/react-packager/src/DependencyResolver/DependencyGraph/HasteMap.js:95:28
at tryCallOne (.../main_application/node_modules/react-native/node_modules/promise/lib/core.js:37:12)
at .../main_application/node_modules/react-native/node_modules/promise/lib/core.js:103:15
at flush (.../main_application/node_modules/react-native/node_modules/promise/node_modules/asap/raw.js:50:29)
at doNTCallback0 (node.js:417:9)
at process._tickCallback (node.js:346:13)

when I add warning.js and also one other file to the blacklist the packager starts but I run into issues once the application starts

@townmi
Copy link

townmi commented Nov 2, 2015

@mangogogos i got the same situation,

Error building DepdendencyGraph:
Error: Naming collision detected: E:\Andriod\AwesomeProject\node_modules\react-native\node_modules\react-tools\src\shared\vendor\core\warning.js collides with E:\Andriod\AwesomeProject\node_modules\react-native\node_modules\react-tools\docs\js\react.js
    at HasteMap._updateHasteMap (E:/Andriod/AwesomeProject/node_modules/react-native/packager/react-packager/src/DependencyResolver/DependencyGraph/HasteMap.js:123:13)
    at E:/Andriod/AwesomeProject/node_modules/react-native/packager/react-packager/src/DependencyResolver/DependencyGraph/HasteMap.js:95:28
    at tryCallOne (E:\Andriod\AwesomeProject\node_modules\react-native\node_modules\promise\lib\core.js:37:12)
    at E:\Andriod\AwesomeProject\node_modules\react-native\node_modules\promise\lib\core.js:103:15
    at flush (E:\Andriod\AwesomeProject\node_modules\react-native\node_modules\promise\node_modules\asap\raw.js:50:29)
    at doNTCallback0 (node.js:417:9)
    at process._tickCallback (node.js:346:13)
PS E:\Andriod\AwesomeProject> react-native -v
0.1.7
PS E:\Andriod\AwesomeProject>

in my node_modules,there is only react-native, no more others. so who can help?

@montogeek
Copy link

I have the same issue

@JeanLebrument
Copy link

Same problem here. I found a workaround: npm prune && npm i

@jpapillon
Copy link

It happened to me when I changed some dependencies in my project. Running ./node_modules/react-native/packager/packager.sh --resetCache fixed the dependencies issue.

@montogeek
Copy link

Is there a way to exclude a folder from the packaging?

@montogeek
Copy link

@jpapillon solution don't works for me

@viatsko
Copy link

viatsko commented Nov 15, 2015

Removing global react-native-cli package worked for me:

npm uninstall -g react-native-cli

@litch
Copy link

litch commented Nov 19, 2015

I'm trying to put a fairly complex react application into a webview in react native (to buy myself a little bit of time to do the "Real" port to RN. But I'm running into this issue. I've tried everything I can think of, but it seems that my compiled app (in dist/assets/main.js is legitimately colliding with the version of invariant that react-tools is trying to pull in.

Am I just totally stuck here until someone figures out how to namespace/scope the Haste modules?

[9:18:47 AM] <START> Building Haste Map
Error building DepdendencyGraph:
 Error: Naming collision detected: /Users/litch/code/Wallet/dist/assets/main.js collides with /Users/litch/code/Wallet/node_modules/react-tools/src/shared/vendor/core/invariant.js
    at HasteMap._updateHasteMap (/Users/litch/code/Wallet/node_modules/react-native/packager/react-packager/src/DependencyResolver/DependencyGraph/HasteMap.js:123:13)
    at /Users/litch/code/Wallet/node_modules/react-native/packager/react-packager/src/DependencyResolver/DependencyGraph/HasteMap.js:95:28
    at tryCallOne (/Users/litch/code/Wallet/node_modules/promise/lib/core.js:37:12)
    at /Users/litch/code/Wallet/node_modules/promise/lib/core.js:103:15
    at flush (/Users/litch/code/Wallet/node_modules/asap/raw.js:50:29)
    at doNTCallback0 (node.js:428:9)
    at process._tickCallback (node.js:357:13)
Process terminated. Press <enter> to close the window

@ide
Copy link
Contributor

ide commented Nov 19, 2015

The packager has a way to configure a blacklist (grep around for the details), which would let you exclude main.js from the JS bundle since RN doesn't need it anyway.

@litch
Copy link

litch commented Nov 19, 2015 via email

@bslayton
Copy link

None of the "solutions" work for me. Anyone have a way around this?

@yarax
Copy link

yarax commented Jan 11, 2016

The same issue. Previous suggestions don't work for me

Error building DependencyGraph:
 Error: Naming collision detected: /Users/native/node_modules/react-native-router/node_modules/react-native/packager/react-packager/src/DependencyResolver/haste/polyfills/String.prototype.es6.js collides with /Users/native/node_modules/react-native/packager/react-packager/src/Resolver/polyfills/String.prototype.es6.js
    at HasteMap._updateHasteMap (HasteMap.js:123:13)
    at HasteMap.js:94:28
    at tryCallOne (/Users/native/node_modules/react-native/node_modules/promise/lib/core.js:37:12)
    at /Users/native/node_modules/react-native/node_modules/promise/lib/core.js:123:15
    at flush (/Users/native/node_modules/react-native/node_modules/promise/node_modules/asap/raw.js:50:29)
    at doNTCallback0 (node.js:417:9)
    at process._tickCallback (node.js:346:13)

@vkhazin
Copy link

vkhazin commented Jan 11, 2016

npm -v; node -v
3.3.12
v5.4.0

Error building DependencyGraph:
Error: Naming collision detected: /Users/vkhazin/Projects/Samples/ReactNative/package.json collides with /Users/vkhazin/Projects/Samples/ReactNative/node_modules/react-native/Libraries/ReactNative/ReactNative.js
at HasteMap._updateHasteMap (HasteMap.js:123:13)
at HasteMap.js:103:32
at tryCallOne (/Users/vkhazin/Projects/Samples/ReactNative/node_modules/promise/lib/core.js:37:12)
at /Users/vkhazin/Projects/Samples/ReactNative/node_modules/promise/lib/core.js:123:15
at flush (/Users/vkhazin/Projects/Samples/ReactNative/node_modules/asap/raw.js:50:29)
at nextTickCallbackWith0Args (node.js:456:9)
at process._tickCallback (node.js:385:13)
~

@martinbigio
Copy link
Contributor

as @ide mentioned you can blacklist files/regexps on the packager. Take a look at packager/blacklist.js :)

@vkhazin
Copy link

vkhazin commented Jan 12, 2016

thank you for your comment martinbigio!
Could you please elaborate a bit more as my experience with React.js is 6 hours old and with React Mobile 2 hours old?

@martinbigio
Copy link
Contributor

@vkhazin absolutely, I'm glad you're giving React Native a try. My comment was for @yarax tough. There's something wrong on your setup. The steps posted on https://facebook.github.io/react-native/docs/getting-started.html should work. Could you give it a try? :)

@martinbigio
Copy link
Contributor

Also, in general it's better to ask these type of questions on Stack Overflow: http://stackoverflow.com/questions/tagged/react-native

@vkhazin
Copy link

vkhazin commented Jan 12, 2016

Hi Martin,

Thank you for your comments!

I did tried twice twice using node 4x and node 5x to make sure the issue is
not related to version of node.
In both cases created the project using the instructions mentioned:
https://facebook.github.io/react-native/docs/getting-started.html and in
both cases ended up with the same error.

On Tue, Jan 12, 2016 at 11:20 AM, Martín Bigio notifications@github.com
wrote:

Also, in general it's better to ask these type of questions on Stack
Overflow: http://stackoverflow.com/questions/tagged/react-native


Reply to this email directly or view it on GitHub
#3558 (comment)
.

Sincerely yours,
Vlad Khazin
Email: vlad.khazin@icssolutions.ca
Skype: vladimir.khazin
Cell: 416-802-2771
Fax: 866-425-2660

http://www.linkedin.com/in/vkhazin

@martinbigio
Copy link
Contributor

I think the problem is related to the fact the project name is ReactNative. cc @mkonicek

@vkhazin
Copy link

vkhazin commented Jan 12, 2016

Here is something to laugh about:

  • named my project ReactNative by calling: 'react-native init ReactNative'
  • project created: /Users/vkhazin/Projects/Samples/ReactNative/
  • try to build:
    Error: Naming collision detected
    Error: Naming collision detected: /Users/vkhazin/Projects/Samples/ReactNative/package.json collides with /Users/vkhazin/Projects/Samples/ReactNative/node_modules/react-native/Libraries/ReactNative/ReactNative.js

Repeat all of the above steps with 'react-native init AwesomeProject' and it runs!

@hiradyazdan
Copy link

I had a similar issue when downgrading from 21 to 18, and uninstalled the react peer dependency and collision error never occurred again.

npm uninstall react --save

@jeanycyang
Copy link

Failed to build DependencyGraph: Naming collision detected: /Users/erwai/Documents/app/MyApp/node_modules/react/node_modules/fbjs/lib/warning.js collides with /Users/erwai/Documents/app/MyApp/node_modules/fbjs/lib/warning.js
Error: Naming collision detected: /Users/erwai/Documents/app/MyApp/node_modules/react/node_modules/fbjs/lib/warning.js collides with /Users/erwai/Documents/app/MyApp/node_modules/fbjs/lib/warning.js
at HasteMap._updateHasteMap (HasteMap.js:132:13)
at HasteMap.js:103:28
at tryCallOne (/Users/erwai/Documents/app/MyApp/node_modules/promise/lib/core.js:37:12)
at /Users/erwai/Documents/app/MyApp/node_modules/promise/lib/core.js:123:15
at flush (/Users/erwai/Documents/app/MyApp/node_modules/asap/raw.js:50:29)
at _combinedTickCallback (node.js:376:9)
at process._tickCallback (node.js:407:11)

npm ERR! Darwin 15.2.0
npm ERR! argv "/Users/erwai/.nvm/versions/node/v5.9.1/bin/node" "/Users/erwai/.nvm/versions/node/v5.9.1/bin/npm" "start"
npm ERR! node v5.9.1
npm ERR! npm v3.8.3

I tried all methods suggested above and none of them works...

I updated my Node & npm versions to the latest versions but it still not working.

@codeopensrc
Copy link

Do yourselves a favor:

  1. watchmen watch-del-all
  2. rm -fr $TMPDIR/react-*
  3. npm cache clean
  4. npm start -- --reset-cache

If you had/have a problem resolving modules:

  • Follow steps 1-3 above and In your package.json file under scripts add:
    "start": "node node_modules/react-native/local-cli/cli.js start --root ../path-to-root/ -- --reset-cache"
  • Create a rn-cli.config.js file where your package.json file is and put in:
'use strict';

const path = require('path');

module.exports = {
    getProjectRoots() {
        return this._getRoots();
    },

    getAssetRoots() {
        return this._getRoots();
    },

    _getRoots() {
        // match on either path separator
        if (__dirname.match(/node_modules[\/\\]react-native[\/\\]packager$/)) {
            // packager is running from node_modules of another project
            return [path.resolve(__dirname, '../../..')];
        } else if (__dirname.match(/Pods\/React\/packager$/)) {
            // packager is running from node_modules of another project
            return [path.resolve(__dirname, '../../..')];
        } else {
            return [
                path.resolve(__dirname, '../'),
                path.resolve(__dirname, '.'),
                path.resolve(__dirname, '../path-to-root/')
            ];
        }
    },
};

Starting with the --reset-cache flag is fairly key. I had it in at one point when attempting to resolve modules then took it out thinking I didn't need it anymore. Once the project blew up for whatever reason the Name collision error popped up. The only thing I actually changed that made it work was re-inputting the --reset-cache flag in the start script after deleting modules, watchmen, and even npm cache cleaning.

Credit goes to @johnknaack for finding the rn-cli-config.js option found in react-native/local-cli/detail.config.js

@joint-song
Copy link

It works for me. @hyphenbash Remove react.

@loloof64
Copy link

loloof64 commented May 3, 2016

Thanks @hyphenbash Also resolved this problem on Ubuntu Linux 15.10 by removing react depency. (I had downgraded from react native 0.24.1 to 0.20.0)

@surendharreddy
Copy link

All, use react-native version 0.26.0. That'll solve your problem.

package.json file

@sushruth
Copy link

sushruth commented Jun 8, 2016

@yarax Apparently having NPM version > 3.0 was the fix for me when i had the exact same issue. Hope this helps if you are still looking.

@dalvik31
Copy link

intenta con este metodo:

http://stackoverflow.com/a/33278101

@brunolemos
Copy link
Contributor

I had this problem because I had a node_modules and a node_modules_bk folder.
It worked after deleting the second one.

@sghiassy
Copy link

sghiassy commented Oct 24, 2016

I was getting errors like

Failed to build DependencyGraph: @providesModule naming collision:
Failed to build DependencyGraph: @providesModule naming collision:
Duplicate module name: accepts
Duplicate module name: accepts

I solved it by deleting npm's cache .npm and rerunning packager with --reset-cache

rm -rf ~/.npm

@andreipt
Copy link

For me the naming collision error was actually caused by using --reset-cache. Running packager without resetting the cache fixes it.

@otech47
Copy link

otech47 commented Apr 21, 2017

If anyone's using react-native-router-flux and ending up here for help check:

aksonov/react-native-router-flux#1803

@facebook facebook locked as resolved and limited conversation to collaborators Jul 21, 2018
@react-native-bot react-native-bot added the Resolution: Locked This issue was locked by the bot. label Jul 21, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Resolution: Locked This issue was locked by the bot.
Projects
None yet
Development

No branches or pull requests