Reputation: 413966
I have a Node project, and I can npm pack
it into a tarball and install it in another directory for testing. When I do that, the set of files in the "bin" clause of my package.json
are correctly symlinked into the node_modules/.bin
directory there. Thus I can use npx something
to run the "something" script and it works as I would expect.
From the actual project directory, however, npm install
doesn't do that. The scripts are there in my top-level "bin" directory of course, but npx
doesn't find them. Obviously I could just run them directly, but it would be nice if I could run the same shell commands to run them in other installation directories and in the project home directory.
I don't want to install the package globally; I want to keep everything local, at least for now. So can I get npm
to make those symlinks for me, or should I just bite the bullet and do it myself?
Here's my package.json
:
{
"name": "@foo/plazadb",
"version": "0.1.0",
"description": "Basic database setup with upload/download from CSV",
"main": "lib/plazadb.js",
"author": "Pointy",
"license": "ISC",
"dependencies": {
"arg": "^5.0.1",
"cls-hooked": "^4.2.2",
"csv-parser": "^3.0.0",
"csv-stringify": "^6.0.5",
"neat-csv": "^7.0.0",
"pg": "^8.7.*",
"sequelize": "^6.16.*"
},
"bin": {
"conntest": "./bin/conntest.js",
"download": "./bin/download.js",
"upload": "./bin/upload.js"
}
}
The "bin" files all exist (of course, otherwise they would never work). What I'm trying (out of ignorance) is a simple npm install
from the project directory.
Upvotes: 3
Views: 3086
Reputation: 1775
One way to do is by
npm config set prefix <path>
or one of these methods linked here.npm link
As a word of caution, to undo npm link
executing npm unlink .
may not work. Instead one may have to run npm uninstall -g .
.
Upvotes: 1