Installation of gulp through node.js's npm breaks windows

我的梦境 提交于 2020-01-14 19:49:08

问题


I want to use gulp on my windows machine and it actually works pretty fine, unless I try to use the created files (like pushing to github or deleting). Then it breaks, because the filepaths are too long and it seems to be a fairly common problem. https://github.com/joyent/node/issues/6960#issuecomment-45569604

I understand that the problem arises through npm's nested directories, which extend the maximal char count for Windows directories, but in my understanding there is not any solution yet.

As I see it right now I have three options:

  1. Try to reduce the chars of npm's directories, by changing the default from 'node_modules' to 'n_m' and hope that problem ist postponed. Like suggested here: https://github.com/joyent/node/issues/6960#issuecomment-45569604

Then it is my question, how exactly do I change the default 'node_modules' directory name?

  1. Change my development environment to Ubuntu, which is frankly a solution I dislike, because I've never used Ubuntu.

  2. Stop using gulp overall.

So, how do I change the default 'node_modules' directory created through npm or what solution do you actually suggest?


回答1:


There is one more tricky option.

Main problem is that gulp has a lot of nested dependencies and it creates very long nested file pathes.

But if you install some of npm modules that gulp requires in your main node_modules directory gulp will not download them as nested.

Currently you have something similar to (this may be not real path you have but idea is the same):

\node_modules\gulp\node_modules\lodash.bind\node_modules\lodash._createwrapper...

If you will add "lodash.bind" module to your project's package.json as dependency it will be installed in one level with gulp and not as gulp's dependency

\node_modules\gulp
\node_modules\lodash.bind\node_modules\lodash._createwrapper

And this will shorter all urls. You will need to fix only one or two with the longest pathes and it will work. In my project it was enough to add this dependencies: “lodash.createcallback” and “lodash.bind” to package.json to fix everything.

Take in mind that befor doing this you probably would need to clear current node_modules folder. If you are not able to do that because off too long url you can create symbolic link to temporary short file path and delete it.



来源:https://stackoverflow.com/questions/24143195/installation-of-gulp-through-node-jss-npm-breaks-windows

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!