Reputation: 25945
I created a sample package and published it into npm registry under my own npm account. Name of my package is newtestmay
. Now when I try to install it using the command npm install newtestmay
I get below error. I've copied the error level logs out of the entire log from npm-debug.log
file which got created by npm in the root of my package where I'm trying to install the package:
128 error Windows_NT 6.1.7601
129 error argv "C:\Program Files\nodejs\node.exe" "C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js" "install" "newtestmay"
130 error node v6.9.1
131 error npm v3.10.8
132 error path D:\rbt\math_user\node_modules\newtestmay\main.js
133 error code ENOENT
134 error errno -4058
135 error syscall chmod
136 error enoent ENOENT: no such file or directory, chmod 'D:\rbt\math_user\node_modules\newtestmay\main.js'
137 error enoent ENOENT: no such file or directory, chmod 'D:\rbt\math_user\node_modules\newtestmay\main.js'
137 error enoent This is most likely not a problem with npm itself
137 error enoent and is related to npm not being able to find a file.
138 verbose exit [ -4058, true ]
package.json
of my newtestmay
package which I had published:
{
"name": "newtestmay",
"version": "1.0.0",
"description": "an example of creating a package",
"main": "bin/main.js",
"bin": {
"mathexample22may": "main.js"
},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [
"math",
"example",
"addition",
"subtraction",
"multiplication",
"division",
"fibonacci"
],
"author": "rasik210",
"license": "ISC"
}
Directory structure of my package:
Code of main.js
:
var path = require('path');
var fs = require('fs');
var lib = path.join(path.dirname(fs.realpathSync(__filename)), '../lib');
var simple = require(lib + '/simple_math.js');
var advanced = require(lib + '/advanced_math.js');
module.exports = {
addition: simple.addition,
subtraction: simple.subtraction,
multiplication: advanced.multiplication,
division: advanced.division,
fibonacci: advanced.fibonacci
}
I'm not able to understand as to why NPM is unable to see main.js
which was present in the bin
directory when I had published the package.
Upvotes: 0
Views: 705
Reputation: 1204
Simple typo: The bin
object of package.json
is all relative to the root of the project. In this case, it should be:
{
...
"bin": {
"mathexample22may": "./bin/main.js"
},
...
}
Upvotes: 1