I am using npm+node for some simple scripting. Minimal example:
I have a node project directory (in which I ran npm init), containing script.js
, package(-lock)?.json
, and node_modules
directory with dependencies. And this script I run from cmdline node "C:/path-to-project/script.js"
.
I want to share this script between 2 computers. I decided to use npm and publish my scripts to registry.
Problems:
MAIN) Installing the package on the other machine, puts it into node_modules
with its dependencies and so cannot be used from the master project directory like on the original machine. Downloading the package with npm-pack
results in desired directory structure, but there is no more the capability to npm-update
the master project (= script.js).
SECONDARY) I am using local dependency, which is added as a link to the node_modules
. I would like to keep it as local link on the original computer, but install it from registry on the second. The dependency is also published, but when installing on second pc, npm fails with Could not install from "node_modules\utils" as it does not contain a package.json file.
The package is scoped, so there is no naming collision and something similar is reported as a bug here https://github.com/npm/npm/issues/18266.
So what is the correct way o achieving my goal? Mainly the first part about installing it as master project and not a dependency while keeping the ability to update to newer version.