然后将其安装在其他电脑上进行检查。 Bu安装包后它和依赖项我尝试启动时有错误
pm ERR! Linux 4.10.0-38-generic
npm ERR! argv "/home/pavlo/.nvm/versions/node/v6.11.4/bin/node" "/home/pavlo/.nvm/versions/node/v6.11.4/bin/npm" "start" "storjboard"
npm ERR! node v6.11.4
npm ERR! npm v3.10.10
npm ERR! path /home/pavlo/Desktop/test/package.json
npm ERR! code ENOENT
npm ERR! errno -2
npm ERR! syscall open
npm ERR! enoent ENOENT: no such file or directory, open '/home/pavlo/Desktop/test/package.json'
npm ERR! enoent ENOENT: no such file or directory, open '/home/pavlo/Desktop/test/package.json'
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! /home/pavlo/Desktop/test/npm-debug.log
问题是我必须从git克隆package.json,我怎么能用package.json正确发布?
注意:命令在package.json脚本中启动
我的json for publish:
{
"name": "name",
"version": "0.0.3",
"description": "Name",
"main": "script.js",
"dependencies": {
"request": "^2.83.0",
},
"devDependencies": {},
"scripts": {
"test": "mocha",
"start": "node node_modules/module/script.js"
},
"repository": {
"type": "git",
"url": "https://github.com/me/module"
},
"keywords": [
"somewords"
],
"author": "me",
"license": "MIT",
"bugs": {
"url": "https://github.com/me/module/issues"
},
"homepage": "https://github.com/me/module#readme"
}
在其他PC上安装模块时出现错误(WARN)
npm WARN enoent ENOENT: no such file or directory, open '/home/pavlo/Desktop/test/package.json'
npm WARN test No description
npm WARN test No repository field.
npm WARN test No README data
npm WARN test No license field.
但是在test/node_modules/module/(here there are everything)
自述文件中,json和脚本
答案 0 :(得分:0)
如果您希望能够从另一个目录启动模块,可以这样做:
在您的模块 package.json
中{
"name": "module",
"scripts": {
"start": "node script.js"
}
}
来自测试目录(如this回答建议):
npm start --prefix node_modules/module/
或者,您可以通过在测试目录中创建package.json文件并添加脚本来启动模块:
{
"name": "test",
"scripts": {
"start": "node node_modules/module/script.js"
}
}
通常 npm 包放在node_modules目录中,因为这些模块应该用作依赖项,而不是直接使用。
这取决于您的应用程序的目的,但也许您可能对安装后脚本或全局安装脚本感兴趣。
npm doc用于软件包安装。