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

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

问题描述

我遇到了一个奇怪的问题 - 显然某些 Node.js 模块具有如此 的文件夹层次结构,以至于 Windows 复制命令(或 PowerShell 的 Copy-Item 这是我们实际使用的)当路径超过 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.

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

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

node_modules
odemailer
ode_modulessimplesmtp
ode_modules
xoauth2
ode_modules
equest
ode_modulesform-data
ode_modules
combined-stream
ode_modulesdelayed-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.0.0flat flat 部分下.

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 上部署具有深层 node_modules 结构的 Node.js 应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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