Using fs.extra copyRecursive gives a “TypeError: forEachAsync is not a function” error and I can't fix it

拈花ヽ惹草 提交于 2021-01-29 08:09:32

问题


My code is : http://pastebin.com/rCy4wSUK

As soon as this function is called by router it prints "done copying contents of clean base into temp" and then error which is here: http://pastebin.com/UxEu4PaS

So at least it is not giving an error in copying but what is causing it to throw this error.


回答1:


Sounds like the fs.extra module has not installed completely and is missing a dependency. Your code runs fine for me with a fresh npm install fs.extra q

Remove your node_modules folder and re-run npm install (if your dependencies are listed in package.json) or npm install fs.extra q (if they are not).




回答2:


I've seen this issue on case-insensitive filesystems in projects that require different versions of walk that depend on forEachAsync@2.x and foreachasync@3.x. Because the casing but not name of foreachasync changed across versions, it seems like it might be confusing npm and not properly installing the right versions.

I was able to fix this in our project by explicitly depending on foreachasync@^3.0.0.



来源:https://stackoverflow.com/questions/38468730/using-fs-extra-copyrecursive-gives-a-typeerror-foreachasync-is-not-a-function

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