Trouble installing with d3-context-menu with bower using VS code

Viewed 117

I am trying to install the d3-context-menu for my vue js and d3.js web app. For reference here is the github here I don't have bower installed so I installed it using

npm install -g bower

Then I ran the command

bower install d3-context-menu

However I get the error message

bower ESUDO         Cannot be run with sudo

Additional error details:
Since bower is a user command, there is no need to execute it with superuser permissions.      
If you're having permission errors when using bower without sudo, please spend a few minutes learning more about how your system should work and make any necessary repairs.

http://www.joyent.com/blog/installing-node-and-npm
https://gist.github.com/isaacs/579814

You can however run a command with sudo using "--allow-root" option

I looked this up online and I cannot find a fix. Would this be because of me using d3v6 or that the context menu github is outdated?

Or is their a better alternative to create a context menu using d3.js?

I am very new to this so any help is greatly appreciated. Thank you

1 Answers

You can use this package in two other ways.

Some examples are described in the README file, here and here, where the author uses the package including the script tag directly in HTML.

<link rel="stylesheet" href="d3-context-menu.css" />
<script src="d3-context-menu.js"></script>

A second way is to install the package using npm. This package is published in the npm registry: https://www.npmjs.com/package/d3-context-menu.

So, theoretically, all you need is:

npm i d3-context-menu

I haven't tested the second way, but the canonical form can be tested directly in the online environment where the examples are, the Plunker platform and it works.

Related