NPM 包未嵌套在具有最新 Node 的 Visual Studio 中 [英] NPM packages not nesting in Visual Studio with latest Node

查看:27
本文介绍了NPM 包未嵌套在具有最新 Node 的 Visual Studio 中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在启动标准 ASP.Net 5 Web 应用程序并添加 npm 包后,VS2015 已停止嵌套它们.即使使用一个简单的包,例如del",我也明白 -

After starting a standard ASP.Net 5 Web Application, and adding npm packages, VS2015 has stopped nesting them. Even with one simple package such as 'del', I see -

我确定它应该只显示主包,它的依赖项嵌套在它下面.VS 现在在所有项目中都这样做,而它们过去是整齐地嵌套的.添加两三个包最终会导致大量且无法管理的无关包列表.

I'm sure it should be showing just the primary package, with its dependencies nested beneath it. VS is now doing this across all projects, whereas they used to be neatly nested. Adding two or three packages ends up with an enormous and unmanageable list of extraneous packages.

如果我从命令提示符运行 npm list,输出会显示所有在 del 下整齐嵌套的包.我试过 npm prunenpm cache clean 但没有成功.如果相关,NPM 会报告节点的 5.4.0 版本和其自身的 3.5.4 版本.

If I run npm list from the command prompt, the output indicates all the packages nested neatly below del. I've tried npm prune and npm cache clean but without success. NPM reports version 5.4.0 of node, and 3.5.4 of itself, if that's relevant.

我想让它表现得像它应该的那样!

I'd like to get it behaving as it should!

编辑 - 只有将默认 Node.js 更改为更新版本时才会发生这种情况.VS2015 Update 1 上的默认值似乎是 NPM 1.4.9、Node 0.10.31.仍然没有帮助.我怀疑如果不更新 Visual Studio,这将无法解决,但可能有一个聪明的方法来解决它.

EDIT - It appears to only happen if you change the default Node.js to a more up-to-date version. The defaults on VS2015 Update 1 appear to be NPM 1.4.9, Node 0.10.31. Still doesn't help though. I suspect this is not going to be resolvable without an update to Visual Studio, but there might be a clever way around it.

推荐答案

EDIT - 这就是答案.

EDIT - Here's the answer.

这个问题的核心是 npm3 决定扁平化模块目录,主要是因为使用不支持长文件路径的旧 API 的 Windows 应用程序存在问题.

The core of this issue is that npm3 has decided to flatten the modules directory, primarily owing to issues with Windows applications using old APIs that don't support long file paths.

长文件路径似乎不是 VS 的问题.由于 npm2 仍在积极维护中,如果您想避免噩梦般的嵌套,您应该使用 npm2 分支.

Long file paths doesn't seem to be an issue with VS. Since npm2 is still being actively maintained, you should use the npm2 branch if you want to avoid nightmare nesting.

但是,更新 node.js 会安装最新的 npm3 分支.要将您的 npm 带回 2 分支,您应该以管理员身份运行 Powershell,然后运行

However, updating node.js installs the latest npm3 branch. To bring your npm back to the 2 branch, you should run Powershell as administrator, and run

npm install -g npm@2.14.14

重启VS.如果您已经有一个扁平化目录,请打开您的 node_modules 文件夹并删除所有内容,然后从 VS GUI 中恢复包.然后你应该回到一个可行的结构.

Restart VS. If you've already got a flattened directory, then open your node_modules folder and delete everything, then Restore Packages from the VS GUI. You should then get back to a workable structure.

(这确实是对迈克尔的回复,但我需要发布一张我无法在评论中做的图片.)

(This is really a reply to Michael, but I need to post an image which I can't do in the comments.)

感谢您澄清立场.如果我指出为什么我认为这是一个非常有问题的职位,我希望你不会介意.

Thank you for clarifying the position. I hope you won't mind if I point out why I think this is a very problematic position.

首先,标准的 npm 包集是完全合理的<代码>"gulp": "3.8.11","gulp-concat": "2.5.2","gulp-cssmin": "0.1.7","gulp-uglify": "1.2.0","rimraf": "2.2.8"

First, the standard set of npm packages is the entirely reasonable "gulp": "3.8.11", "gulp-concat": "2.5.2", "gulp-cssmin": "0.1.7", "gulp-uglify": "1.2.0", "rimraf": "2.2.8"

这是生成的包列表:

我想你马上就会明白这是多么行不通.

I think you can see straight away how that's pretty unworkable.

其次,无法卸载软件包.

Second, it becomes impossible to uninstall a package.

第三,有一些嵌套,但为什么以及如何嵌套有点神秘.

Third, there is some nesting, but quite why and how is a bit of a mystery.

必然会列出安装在 DNX 下的每个 ASP.Net 包——实际上可能有数百个,而且它同样是行不通的.

The corollary would be listing every ASP.Net package that's installed under DNX - there would be literally hundreds, and it would be similarly unworkable.

我不完全理解字符限制问题,但在我看来更像是一个 GUI 问题.再次感谢.

I don't fully understand the character limit issue, but it seems to me to be more a GUI issue. Thanks again.

这篇关于NPM 包未嵌套在具有最新 Node 的 Visual Studio 中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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