简体   繁体   中英

Create local npm package with local dependencies and install it in another package

I have created three different custom modules.

  1. getcorrespondence-1.0.0.tgz
  2. getrediscache-1.0.0.tgz
  3. setrediscache-1.0.0.tgz

I have created these custom node module using npm pack command. The module getcorrespondence-1.0.0.tgz has dependencies on another two custom modules (getrediscache-1.0.0.tgz, setrediscache-1.0.0.tgz) which are created locally.

The problem that I am facing is that when I try to install getcorrespondence-1.0.0.tgz in another node project, it throws the error as below:

npm install getcorrespondence-1.0.0.tgz npm ERR! addLocal Could not install C:\\Repos\\Microservices_APIs\\PaymentsAPI\\CommonAPI.Specs.Unit\\getcorrespondence-1.0.0.tgz\\getrediscache-1.0.0.tgz npm ERR! addLocal Could not install C:\\Repos\\Microservices_APIs\\PaymentsAPI\\CommonAPI.Specs.Unit\\getcorrespondence-1.0.0.tgz\\setrediscache-1.0.0.tgz npm ERR! Windows_NT 10.0.10240 npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install" "getcorrespondence-1.0.0.tgz" npm ERR! node v6.3.1 npm ERR! npm v3.10.3 npm ERR! path C:\\Repos\\Microservices_APIs\\PaymentsAPI\\CommonAPI.Specs.Unit\\getcorrespondence-1.0.0.tgz\\getrediscache-1.0.0.tgz npm ERR! code ENOENT npm ERR! errno -4058 npm ERR! syscall open

npm ERR! enoent ENOENT: no such file or directory, open 'C:\\Repos\\Microservices_APIs\\PaymentsAPI\\CommonAPI.Specs.Unit\\getcorrespondence-1.0.0.tgz\\getrediscache-1.0.0.tgz' npm ERR! enoent ENOENT: no such file or directory, open 'C:\\Repos\\Microservices_APIs\\PaymentsAPI\\CommonAPI.Specs.Unit\\getcorrespondence-1.0.0.tgz\\getrediscache-1.0.0.tgz' npm ERR! enoent This is most likely not a problem with npm itself npm ERR! enoent and is related to npm not being able to find a file. npm ERR! enoent npm ERR! Please include the following file with any support request: npm ERR! C:\\Repos\\Microservices_APIs\\PaymentsAPI\\CommonAPI.Specs.Unit\\npm-debug.log

My package.json file for getcorrespondence-1.0.0.tgz is :

{
   "name": "getcorrespondence",
   "version": "1.0.0",
   "description": "Get Correspondence Module",
    "author": {
       "name": "XYZ",
       "email": ""
    },
    "dependencies": {
       "getrediscache": "file:./getrediscache-1.0.0.tgz",
       "jslinq": "^1.0.15",
       "setrediscache": "file:./setrediscache-1.0.0.tgz",
       "soap": "^0.16.0"
    }
}

What changes are required to correctly install the package.

After creating the getcorrespondence package, my tgz file look like:

在此输入图像描述

NPM's errors are usually frustratingly cryptic. The relevant part in that wall of text is no such file or directory, open 'C:\\Repos\\Microservices_APIs\\PaymentsAPI\\CommonAPI.Specs.Unit\\getcorrespondence-1.0.0.tgz\\getrediscache-1.0.0.tgz' , which basically means npm expected the file to exist in that path, but it isn't.

I assume the cause is an incorrect path in your package.json .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM