Exactly how install jsx-tikzcd using npm?


(Murray Eisenberg) #1

Under macOS I’ve downloaded the jsx-tikzcd package (https://github.com/yishn/jsx-tikzcd), into a folder named “jsx-tikzcd-master”. Its docs say to install it using the command:

npm install jsx-tikzcd

If I cd to my home directory, or to that directory, and try executing that npm command, I get error:

Refusing to install package with name "jsx-tikzcd" under a package
npm ERR! also called "jsx-tikzcd". Did you name your project the same
npm ERR! as the dependency you're installing?

Being a complete newbie to npm, I don’t understand what else I’m supposed to do to avoid that error and complete the installation.

The file tree of jsx-tikzcd-master is:
├── LICENSE
├── README.md
├── demo.png
├── dist
│ ├── jsx-tikzcd.js
│ └── jsx-tikzcd.js.map
├── package-lock.json
├── package.json
├── rollup.config.js
├── src
│ ├── components.js
│ ├── h.js
│ ├── index.js
│ └── render.js
└── test
└── test.js

File package.json begins:

{
  "name": "jsx-tikzcd",
  "version": "0.5.0",
  "description": "Render tikzcd diagrams with JSX.",
  "main": "./dist/jsx-tikzcd",
  "module": "./src/index",
  "repository": {
    "type": "git",
    "url": "git+https://github.com/yishn/jsx-tikzcd.git"
  },

(Lars Willighagen) #2

You don’t have to download the code from GitHub to use it in your project. If you have a project directory already, run

npm install jsx-tikzcd

from there. This automatically downloads the code to the right place. If you don’t have a project directory yet, here’s a guide on how to create one.

You should also be able to install the code to your home directory. However, I see that doesn’t work. Are you getting the same error as before, “Refusing to install package with name “jsx-tikzcd” under a package also called “jsx-tikzcd”.”? If so, is there a package.json file in your home directory?


(Murray Eisenberg) #3

I find no package.json file in my home directory (i.e., at the top level /Users/me).

In any case, what exactly is the syntax to indicate both the (local) source folder for the package to be installed and the location into which it is to be installed? That is one thing I do not understand.


(Murray Eisenberg) #4

I tried but failed to understand the linked instruction on how to create a project directory. Those instructions begin by talking about creating a package.json file in the root directory of my Node.js module. But what is mean by “the root directory of my Node.js module” and, for that matter, what is meant by “my Node.js module”? I don’t have any “node” or “module” yet; I want to be able to use jsx-tikzcd!


(John Gee) #5

I do not think jsx-tikzcd is a tool you can use on its own to draw the nice pictures, if that was what you wanted. So getting it “installed” on its own may not get you much further. However, the npm steps are:

mkdir MyProgram
cd MyProgram
npm init
# (answer the questions, default answers are ok)
npm install jsx-tikzcd

(Murray Eisenberg) #6

I used mkdir to create a directory not named jsx-tikzcd, cdd to it, and ran npm init. In answering the questions, I did not know what to answer, really, so I used the same information I found in the jsx-tikzcd package.json, including naming the package jsx-tikzcd. Finally, when I ran npm install jsx-tikzcd I get the same error as before:

Refusing to install package with name "jsx-tikzcd" under a package
npm ERR! also called "jsx-tikzcd". Did you name your project the same
npm ERR! as the dependency you're installing?

Clearly I don’t understand or don’t know what I’m doing or supposed to be doing here to get this installed.


(Murray Eisenberg) #7

Aha: I repeated those steps but this time using the package name my_jsx-tikzcd in response to the prompt from npm init. Now I have jsx-tikzcd installed.

Now I have to figure out how to install JSX, configure it for Babel (from TeX-land), and execute code that creates and renders TikZ diagrams.

(I do wish that authors of packages such as jsx-tikzcd would spell out explicitly what they, as experts, already understand for those of us who didn’t create the software!)


(system) closed #8

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.