React-Native Packager Failure: Duplicate module name - node.js

This happened seemingly randomly during development. When trying to run npm start or react-native run-ios, I get the following error:
Failed to build DependencyGraph: #providesModule naming collision:
Duplicate module name: react-native-vector-icons
Paths: /Users/chandlervdw/Repos/Relay/mobile/node_modules/react-native/local-cli/rnpm/core/test/fixtures/files/package.json collides with /Users/chandlervdw/Repos/Relay/mobile/node_modules/react-native/Libraries/Animated/release/package.json
This error is caused by a #providesModule declaration with the same name accross two different files.
Error: #providesModule naming collision:
Duplicate module name: react-native-vector-icons
Paths: /Users/chandlervdw/Repos/Relay/mobile/node_modules/react-native/local-cli/rnpm/core/test/fixtures/files/package.json collides with /Users/chandlervdw/Repos/Relay/mobile/node_modules/react-native/Libraries/Animated/release/package.json
This error is caused by a #providesModule declaration with the same name accross two different files.
at HasteMap._updateHasteMap (/Users/chandlervdw/Repos/Relay/mobile/node_modules/node-haste/lib/DependencyGraph/HasteMap.js:162:15)
at /Users/chandlervdw/Repos/Relay/mobile/node_modules/node-haste/lib/DependencyGraph/HasteMap.js:140:25
Strangely, /Users/chandlervdw/Repos/Relay/mobile/node_modules/react-native/local-cli/rnpm/core/test/fixtures/files/package.json actually does list react-native-vector-icons as the name for the module???
If I delete that file, the error no longer happens but the packager gets stuck at 93% and complains about a completely irrelevent library not being found.
I blew away my repo and even reinstalled everything, including npm, rnpm, and even upgrading node. I'm running the same versions of everything as my teammates, who are able to run the packager without issues.

Posting this as an answer just in case anybody else has this issue in future.
Running npm start with sudo permissions grants the correct privileges when nodes package manager is running the initial build phase. This only seems to happen if the shell/user that you are running from has restricted privileges. Force escalating privileges to sudo gives the package manager full control to complete the build.

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

sudo or chown did not fix it for me. I get the same error from the same library, very odd:
Failed to build DependencyGraph: #providesModule naming collision:
Duplicate module name: react-native-vector-icons
Paths: /Users/collumj/research/k9fresh/ios/build/Build/Products/Debug-iphonesimulator/kisharNine.app/package.json collides with /Users/collumj/research/k9fresh/node_modules/react-native/local-cli/core/__fixtures__/files/package.json
No need for sudo when I encounter this.
Warning: destructive, check in first.
rm -rf android ios
git reset --hard
npm start
This fixes it every time. RN 0.39.2
edit: later, I think I fixed this by unlinking the react-native-vector-icons lib; I think the instructions I got made me double up on the linking or were out of date somehow.

After cleaning the nvm cache and reinstalling all node_modules I realized I was having this issue because of react-native-router-flux.
I fixed it with a downgrade from react-native-router-flux#3.38.1 to react-native-router-flux#3.38.0
More details here:
https://github.com/aksonov/react-native-router-flux/issues/1816

Related

The target entry-point "#vcd/ui-components" has missing dependencies:

I'm getting the following error when I npm start the application at https://github.com/juanmendes/vmware-cloud-director-ui-components for the branch named ryan-a11y-merge-to-master. If I run the master branch, I get no errors.
ERROR in The target entry-point "#vcd/ui-components" has missing dependencies:
- #angular/core
- #clr/angular
- #angular/common
- rxjs/internal-compatibility
- #angular/platform-browser
- #angular/core/testing
- #angular/forms
- #angular/router
- rxjs
- rxjs/operators
- #clr/angular/data/datagrid/interfaces/filter.interface
I also see the following error messages before this final error:
Warning: Entry point '#vmw/ng-live-docs' contains deep imports into '/Users/jmendes/git/github/juan-core-ui/node_modules/prismjs/components/prism-scss', '/Users/jmendes/git/github/juan-core-ui/node_modules/prismjs/components/prism-typescript'. This is probably not a problem, but may cause the compilation of entry points to be out of order.
Warning: Entry point '#vmw/plain-js-live-docs' contains deep imports into '/Users/jmendes/git/github/juan-core-ui/node_modules/lit-html/directives/unsafe-html'. This is probably not a problem, but may cause the compilation of entry points to be out of order.
Warning: Entry point '#vcd/ui-components' contains deep imports into '/Users/jmendes/git/github/juan-core-ui/node_modules/#clr/angular/data/datagrid/interfaces/filter.interface'. This is probably not a problem, but may cause the compilation of entry points to be out of order.
If I ask colleagues to clone that repo and run it:
git clone https://github.com/juanmendes/vmware-cloud-director-ui-components.git
cd vmware-cloud-director-ui-components;
git checkout ryan-a11y-merge-to-master;
npm ci;
npm start;
They have been able to run the application (and also get the warnings) without a problem but I get the error above and get the following message at localhost:4200: Cannot GET /
What I have tried
Deleted node_modules and the dist folder
npm cache clean
npm unlink #angular/core (both steps in the package folder and the project including it)
npm unlink #vcd/ui-components (both steps)
Completely removing node, npm, nmv and reinstalling them
Workaround
If I disable Ivy compilation, then it complains because one of the packages it uses (#vmw/live-docs), doesn't declare entryComponents for some dynamically created components (since they are not needed in Ivy compilation).
To get past that problem, I modified the code in #vmw/live-docs to have entryComponents and re-built it, copying its dist folder to node_modules in my current application. This allows me to run the app in non Ivy mode, which is not what I want
What else can I try ?
I am out of things to try, any suggestions are welcome.
This was happening because I somehow had a ~/node_modules/#vcd/ui-components with stale references.
It seems that node module resolution was going up the tree and trying to use that version instead of the one I had configured in ~/github/vmware-cloud-director-ui-components/tsconfig.json
"compilerOptions": {
"paths": {
"#vcd/ui-components": [
"../../dist/components"
]
}
},
Deleting that node_modules folder fixed my problem

angular project npm modules randomly deleted

I have the weirdest problem I've ever seen with npm where in the middle of running an angular ng serve, packages from both node and for angular will randomly go missing. In the middle of a save, the project will suddenly not recompile, and will complain about a missing module. Each time it has been different but so far I have had:
Error: ENOENT: no such file or directory, open '.../node_modules/core-js/internals/hidden-keys.js'
Module not found: Error: Can't resolve '../internals/is-pure' in '/.../node_modules/#angular-devkit/build-angular/node_modules/core-js/internals'
An unhandled exception occurred: Cannot find module './internal/streams/stream
An unhandled exception occurred: Cannot find module '/.../node_modules/minipass-collect/node_modules/minipass/index.js'.
Please verify that the package.json has a valid "main" entry
These have just been errors from the last few days, but issues like this has been happening all. to the point where I need to delete node_modules and reinstall everything via npm at least once a day. I'm thinking the error has more to do with node or NPM than with my Angular set up, as some of these missing packages appear to be node core packages.
I've already tried reinstalling npm globally via npm install -g npm and it hasn't helped anything. I'm afraid that I'm going to have to just reinstall node completely.
Any help would be appreciated, thank you.
EDIT: upon further debugging, I'm noticing that the modules missing are always from #angular-devkit/build-angular/node_modules/core-js/modules. In addition to losing random modules like 'is-pure', the app will also randomly recompile many times when running ng serve
I figured out what was going on, if anyone in the future has the same problem. Turns out the answer has nothing to do with me botching my npm config. I didn't realize that on new Macbooks, any directory in the desktop is automatically managed by iCloud. At some point, probably an older version of the code before I migrated to Angular 9 was syncing the old code into my project. I was able to resolve this issue by changing the name of the parent directory where my project lived from filename to filename.nosync. adding '.nosync' causes iCloud to ignore syncing for whatever is in that file. I know I should have caught this, but hopefully this will help any mac users in the future who are experiencing similar problems.

Getting error when deploying a Google Cloud Function after Node upgrade

I updated Brew then updated Node from 10.12.0 -> 13.8.0
Now, I get the following error when trying to deploy a Google Cloud Function
firebase deploy --only functions:createJWT
i functions: preparing functions directory for
uploading...
Error: Error parsing triggers: Failed to load gRPC binary module
because it was not installed for the current system Expected
directory: node-v79-darwin-x64-unknown Found:
[node-v64-darwin-x64-unknown] This problem can often be fixed by
running "npm rebuild" on the current system Original error: Cannot
find module
'/Users/.../cloud-functions/functions/node_modules/grpc/src/node/extension_binary/node-v79-darwin-x64-unknown/grpc_node.node'
Require stack:
- /Users/.../cloud-functions/functions/node_modules/grpc/src/grpc_extension.js
- /Users/.../cloud-functions/functions/node_modules/grpc/src/client_interceptors.js
- /Users/.../cloud-functions/functions/node_modules/grpc/src/client.js
- /Users/.../cloud-functions/functions/node_modules/grpc/index.js
- /Users/.../cloud-functions/functions/node_modules/#google-cloud/common-grpc/src/service.js
- /Users/.../cloud-functions/functions/node_modules/#google-cloud/common-grpc/src/operation.js
- /Users/.../cloud-functions/functions/node_modules/#google-cloud/common-grpc/src/index.js
- /Users/.../cloud-functions/functions/node_modules/#google-cloud/logging/src/index.js
- /Users/.../cloud-functions/functions/index.js
- /usr/local/lib/node_modules/firebase-tools/lib/triggerParser.js
Try running "npm install" in your functions directory before
deploying.
Tried npm rebuild and npm install in my functions directory and nothing works
Furthermore...could this issue be due to the fact that GCF Node runtime enviroment is Node10 and I have installed Node13 on my machine? - according to these docs:
https://cloud.google.com/functions/docs/concepts/nodejs-10-runtime
I am struggling to revert back to Node10, have tried by running brew install node#10 and get this:
Then tried running the following command as per output above to symlink it to /usr/local but still no luck
echo 'export PATH="/usr/local/opt/node#10/bin:$PATH"' >> ~/.bash_profile
Searching around about this error, indeed, this seems that the problem is related to your system waiting for a version and founding another one - as per this part of the error.
Error: Error parsing triggers: Failed to load gRPC binary module because it was not installed for the current system Expected directory: node-v79-darwin-x64-unknown Found: [node-v64-darwin-x64-unknown]
There are some options that you can give it a try, besides trying the npm rebuild. Another option might be updating the package.json - as per this case solved here - that would return your npm version to an old one.
Besides that, on this question in the Community, there are a few solutions that helped other users, that I would recommend you to take a look at it: NodeJs Error - Failed to load gRPC binary module because it was not installed for the current system Expected directory?
Let me know if the information helped you!
Trying to deploy to an unsupported Google Function execution environment won't work. According to the google docs the current supported environments are Node8 and Node10(beta), re-installing Node10 worked for me.

Error when building brunch with banana pancakes

I created a brunch project with the banana pancakes skeleton
brunch new brunchtest -s github://Anaphase/brunch-banana-pancakes
Then when building I get an error
cd brunchtest
brunch build
-> error: { [Error: Cannot find module '/media/sf_C_DRIVE/wamp/www/test/brunchtest/node_modules/clean-css-brunch'] code: 'MODULE_NOT_FOUND' }
So its obvious that some modules are missing but why? The strange part is that when I create the project I see that these modules are downloaded and put into node_modules but then they are removed during the creation process and only these remain:
Here's the whole npm-debug.log file, I see there are some errors but I don't know what they mean
http://pastebin.com/E4eMFeiC
Update
Here's a screenshot of the installation process errors (which should be in the logfile but I guess this is more convenient)
As per MrAzulay's comment, there's a security setting in Virtualbox that disables symlinking. He says he's had success with the following command, which I haven't tested:
VBoxManage setextradata VM_NAME VBoxInternal2/SharedFoldersEnableSymlinksCreate 1

npm doesn't build Contextify Release - node path not found?

I'm working on packaging a node app to be deployed on a server without npm. I believe I have it figured out - I used npm to install all the dependencies in a local node_modules folder according to a package.json file.
It all appears to work well, but when I attempt to run the node file from the server, it complains that it Cannot find module '../build/Release/contextify'.
That makes sense, because in node_modules/.npm/contextify/0.0.4/package/lib/contextify.js, it asks for the file in question, and node_modules/.npm/contextify/0.0.4/package/build has no directory called Release. I assumed that npm just hadn't built the release, so I switched back to the dev machine, and ran npm install - it didn't complain, and it appeared to build contextify:
$ sudo npm install
> contextify#0.0.4 preinstall /path/to/node/stuff/node_modules/contextify
> node-waf clean || true; node-waf configure build
'clean' finished successfully (0.014s)
Setting srcdir to : /path/to/node/stuff/node_modules/.npm/contextify/0.0.4/package
Setting blddir to : /path/to/node/stuff/node_modules/.npm/contextify/0.0.4/package/build
Checking for program g++ or c++ : /usr/bin/g++
Checking for program cpp : /usr/bin/cpp
Checking for program ar : /usr/bin/ar
Checking for program ranlib : /usr/bin/ranlib
Checking for g++ : ok
Checking for node path : not found
Checking for node prefix : ok /usr/local/Cellar/node/0.4.5
'configure' finished successfully (0.043s)
Waf: Entering directory `/path/to/node/stuff/node_modules/.npm/contextify/0.0.4/package/build'
[1/2] cxx: src/contextify.cc -> build/default/src/contextify_1.o
[2/2] cxx_link: build/default/src/contextify_1.o -> build/default/contextify.node
Waf: Leaving directory `/path/to/node/stuff/node_modules/.npm/contextify/0.0.4/package/build'
'build' finished successfully (0.370s)
unfortunately, the package/build directory still doesn't have a Release folder.
So, I guess the question is if contextify is failing to build because my node path isn't set (I tried export NODE_PATH, but it didn't seem to help...), or if there is some other reason that contextify doesn't appear to be building.
Maybe I'm missing something larger?
I too am having the same issue,
You may want to add the issue to github, the author may be able to help you sooner than on here.
https://github.com/brianmcd/contextify/issues?sort=created&direction=desc&state=closed&page=1
The fix for this error is just to remove waf's "build" directory, then re-configure. Somehow waf caches the bad config result due to a missing NODE_PATH, so even if you then remember and set it, it won't actually compile anything despite the configure reporting no errors. Silly!
export NODE_PATH="/usr/local/lib/node_modules/"
rm -fr build
node-waf configure
node-waf build
I think your local version of nodejs is v.0.4.* and your server version of nodejs is v0.5.*
Make sure you use the same version of nodejs for dev and production. If you switch to v0.4.* I bet your problem will be solved. I noticed that the node-waf 'build' configuration is switched from 'default' to 'Release' somewhere in the 5.* versions.
One warning however:
Some npm packages are using (compiled) binaries. I.M.O, you should not bundle 'compiled' node_modules in one package to deploy it on a 'different' platform without npm. It's a matter of time before you will running into problems. (like the one above)

Resources