npm 3.x install fails on rename long paths in Windows/Azure

*爱你&永不变心* 提交于 2019-12-07 12:35:37

问题


npm 3.x install fails on rename long paths in Windows/Azure when deploying node.js due to long paths:

npm ERR! EINVAL: invalid argument, rename 'D:\home\site\wwwroot\node_modules\azure_util\node_modules\pkgcloud\node_modules\gcloud\node_modules\gapitoken\node_modules\jws\node_modules\base64url\node_modules\meow\node_modules\indent-string\node_modules\repeating\node_modules\is-finite\node_modules\number-is-nan' -> 'D:\home\site\wwwroot\node_modules\number-is-nan'

Is there away to overcome it or prevent npm from renaming?


回答1:


We found a solution. It seems like npm 3.x is getting to this situation when it needs to rename a long path only when you upgrade from older npm.

Meaning, since we already had this deployment running with an older npm, when we upgraded to npm 3.6.0 it tried to flatten the existing deployment and crashed.

The solution was just to remove the node_modules and redeploy.




回答2:


According your info, your custom module azure_util is build in npm <3.x version, which has nested the node_modules folders.

You can try the following steps before deploying your node.js application to Azure Web Apps:

  1. upgrade your local npm version up to 3.x version.
  2. run command npm dedupe in your application directory, which will flatten the tree. You can find the description in npm change log

After these operations, your application's node.js deps should flat list in node_modules folder. And it should prevent the npm rename.

If you still occur the issue on your local env, you can try to rebuild your custom dependency in npm 3.x version, to make the directory tree flat in advance.



来源:https://stackoverflow.com/questions/35412935/npm-3-x-install-fails-on-rename-long-paths-in-windows-azure

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