Search code examples
javascriptnpmcommand-linenpm-installnpx

Global NPM package not installing


I have written a command line utility in JS which can be used to backup data to IPFS.

https://www.npmjs.com/package/ipfs-backup

When I am attempting to install it with npm install -g ipfs-backup I am getting an error which prevents the package from being installed.

The terminal is outputting the following:

npm ERR! code ENOENT
npm ERR! syscall chmod
npm ERR! path C:\Users\jwhit\AppData\Roaming\npm\node_modules\ipfs-backup\node index.js
npm ERR! errno -4058
npm ERR! enoent ENOENT: no such file or directory, chmod 'C:\Users\jwhit\AppData\Roaming\npm\node_modules\ipfs-backup\node index.js'
npm ERR! enoent This is related to npm not being able to find a file.

Solution

  • The issue turned out to be that within my package.json file I had

    "bin": {
        "ipfs-backup": "node index.js",
        "ipfs-restore": "node restore.js"
    }
    

    instead of

    "bin": {
        "ipfs-backup": "./index.js",
        "ipfs-restore": "./restore.js"
    }
    

    It installs and functions correctly now.