admin管理员组文章数量:1312879
I have a small script that uses npm pack
to package a certain nodejs module. When I unpack the .tgz
created by the npm pack
mand the directory inside is named package
. My question is if there's a way to rename this package to the acutal name of the project?
Package.json
{
"name": "package_name",
"version": "0.0.3",
"description": "A description",
"main": "server.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"dependencies": {
"request": "2.55.0"
},
"devDependencies": {
"grunt": "0.4.5",
"grunt-contrib-concat": "0.5.1"
}
}
Here's to code I'm using, might be helpful.
npm.load('./some/path', function (er) {
if (er) {
res.send("er");
}
npmmands.pack(['./another/path'], function (er, data) {
if (er) {
res.send("error");
}
var fileName = __dirname+"/projectName-0.0.3.tgz";
res.sendFile(fileName, {
headers: {
"Content-Type": "application/x-tar"
}
});
});
I have a small script that uses npm pack
to package a certain nodejs module. When I unpack the .tgz
created by the npm pack
mand the directory inside is named package
. My question is if there's a way to rename this package to the acutal name of the project?
Package.json
{
"name": "package_name",
"version": "0.0.3",
"description": "A description",
"main": "server.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"dependencies": {
"request": "2.55.0"
},
"devDependencies": {
"grunt": "0.4.5",
"grunt-contrib-concat": "0.5.1"
}
}
Here's to code I'm using, might be helpful.
npm.load('./some/path', function (er) {
if (er) {
res.send("er");
}
npm.mands.pack(['./another/path'], function (er, data) {
if (er) {
res.send("error");
}
var fileName = __dirname+"/projectName-0.0.3.tgz";
res.sendFile(fileName, {
headers: {
"Content-Type": "application/x-tar"
}
});
});
Share
Improve this question
edited Apr 18, 2015 at 13:23
cbass
asked Apr 18, 2015 at 13:04
cbasscbass
2,5583 gold badges29 silver badges39 bronze badges
3
-
The tar created by
npm pack
seems required to have a specific format. Since it serves the purpose of being public via npm repository – Kirill Slatin Commented Apr 18, 2015 at 13:38 -
According to last mit to
pack.js
in npm it is impossible to override this behavior unless you rebuild your own npm – Kirill Slatin Commented Apr 18, 2015 at 13:44 - I have the same question, I opened an issue here: github./npm/npm/issues/10227 – nnyby Commented Nov 2, 2015 at 16:20
1 Answer
Reset to default 5@Kirill Slatin is correct. The npm pack
format is intended for internal consumption, so npm does not provide an affordance for changing the name from package
to something else.
However, you can change the names while extracting if your tar
supports the -s
switch. On OSX, you can do:
tar -xvz -s/package/foo/ -f foo-1.0.0.tgz
(Edited, thanks David G for pointing out the error.)
本文标签: javascriptNPM Pack Rename package directoryStack Overflow
版权声明:本文标题:javascript - NPM Pack: Rename package directory - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741884959a2402968.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论