如何在Windows上部署具有deep node_modules结构的Node.js应用程序? [英] How to deploy Node.js application with deep node_modules structure on Windows?

查看:708
本文介绍了如何在Windows上部署具有deep node_modules结构的Node.js应用程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到了一个好奇的问题 - 显然一些Node.js模块有这样的 深层文件夹层次结构,Windows拷贝命令(或PowerShell的当路径超过250个字符长时,复制项目这是我们实际使用的)点击臭名昭着的路径太长错误。

I've run into a curious issue - apparently some Node.js module have so deep folder hierarchies that Windows copy command (or PowerShell's Copy-Item which is what we're actually using) hits the infamous "path too long" error when path is over 250 chars long.

例如,这是单个节点模块可以创建的文件夹层次结构:

For example, this is a folder hierarchy that a single Node module can create:

node_modules\nodemailer\node_modules\simplesmtp\node_modules\
xoauth2\node_modules\request\node_modules\form-data\node_modules\
combined-stream\node_modules\delayed-stream\...

看起来很疯狂,但现在是Node模块。

It seems insane but is a reality with Node modules.

我们需要在部署过程中使用复制粘贴(我们并没有使用一个聪明的目标平台,如Heroku,Git部署将是一个选项),这是对Windows的严重限制。

We need to use copy-paste during deployment (we're not using a "clever" target platform like Heroku where Git deployment would be an option) and this is a serious limitation on Windows.

是不是有一个npm命令或一些可以压缩 node_modules 文件夹的东西,或者可能只包含运行时实际需要的东西?(节点模块通常包含 test 文件夹等,我们不需要部署。)任何其他想法如何解决?不使用Windows不幸的是不是一个选择:)

Isn't there a npm command or something that would compact the node_modules folder or maybe include only what's actually necessary at runtime? (Node modules usually contain test folders etc. which we don't need to deploy.) Any other ideas how to work around it? Not using Windows is unfortunately not an option :)

推荐答案

npm v3(最近发布)通过展平依赖关系来解决这个问题。在 https://github.com/npm/npm/releases/tag/v3中查看发行说明 flat flat section。

npm v3(released recently) solves this issue by flattening out the dependencies.. Check the release notes here in https://github.com/npm/npm/releases/tag/v3.0.0 under flat flat section.

此问题的最后一条评论https://github.com/npm/npm/issues/3697

And the last comment on this issue https://github.com/npm/npm/issues/3697

这篇关于如何在Windows上部署具有deep node_modules结构的Node.js应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆