在 npm 注册表中安装我发布的包时出错 - Errorno - 4058。没有这样的文件或目录 main.js 错误
Error installing my published package in npm registry - Errorno - 4058. No such file or directory main.js error
我创建了一个示例包并将其发布到我自己的 npm 帐户下的 npm 注册表中。我的包裹名称是 newtestmay
。现在,当我尝试使用命令 npm install newtestmay
安装它时,出现以下错误。我已经从 npm-debug.log
文件中复制了整个日志中的错误级别日志,该文件由 npm 在我尝试安装包的根目录中创建:
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 ]
我发布的 newtestmay
包的 package.json
:
{
"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"
}
我的包的目录结构:
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
}
我无法理解为什么 NPM 无法看到 main.js
,它在我发布包时出现在 bin
目录中。
简单错别字:package.json
的bin
对象都是相对于项目根目录的。在这种情况下,它应该是:
{
...
"bin": {
"mathexample22may": "./bin/main.js"
},
...
}
我创建了一个示例包并将其发布到我自己的 npm 帐户下的 npm 注册表中。我的包裹名称是 newtestmay
。现在,当我尝试使用命令 npm install newtestmay
安装它时,出现以下错误。我已经从 npm-debug.log
文件中复制了整个日志中的错误级别日志,该文件由 npm 在我尝试安装包的根目录中创建:
我发布的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 ]
newtestmay
包的 package.json
:
{
"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"
}
我的包的目录结构:
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
}
我无法理解为什么 NPM 无法看到 main.js
,它在我发布包时出现在 bin
目录中。
简单错别字:package.json
的bin
对象都是相对于项目根目录的。在这种情况下,它应该是:
{
...
"bin": {
"mathexample22may": "./bin/main.js"
},
...
}