node.js 更改 npm-debug.log 位置
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/21624030/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Change npm-debug.log location
提问by hsz
When I run npm startand there is some error, it says:
当我运行时npm start出现一些错误,它说:
npm ERR! Additional logging details can be found in:
npm ERR! /home/hsz/Projects/project/npm-debug.log
npm ERR! not ok code 0
And this file is located in a directory from which I have called npm.
这个文件位于我调用的目录中npm。
Is it possible to set npm-debug.logoutput file to ./logs/npm-debug.log?
是否可以将npm-debug.log输出文件设置为./logs/npm-debug.log?
采纳答案by Omar Al-Ithawi
Update:
更新:
npm pull request #6744tries to move npm-debug.logfrom cwd into the cache folder.
npm pull request #6744尝试npm-debug.log从 cwd移动到缓存文件夹。
Original Answer:
原答案:
There doesn't seem to be a way to do this. It is hardcoded:
似乎没有办法做到这一点。它是硬编码的:
if (wroteLogFile) {
log.error("", [""
,"Additional logging details can be found in:"
," " + path.resolve("npm-debug.log")
].join("\n"))
wroteLogFile = false
}
log.error("not ok", "code", code)
I don't think this flexibility would fit into npm's philosophy see isaacs comment:
我认为这种灵活性不符合npm的理念,请参阅isaacs 评论:
npm config set prefix?If you want to spell "node_modules" differently, sorry, no can do. That's built into node-core. Changing that is tantamount to building a completely different package manager.
npm config set prefix?如果您想以不同的方式拼写“node_modules”,抱歉,没有办法。那是内置在节点核心中的。改变它等同于构建一个完全不同的包管理器。

