DeprecationWarning: Buffer() is deprecated due to security and usability issues. Please use the Buffer.alloc(), … methods instead

狂风中的少年 提交于 2019-12-11 03:26:47

问题


I have an angular project and recently I have added angular-universal to it using the following command:

ng add @nguniversal/express-engine --clientProject {{ name of your project }}

building and running it:

npm run build:ssr && npm run serve:ssr

Ive got many errors after doing so but I managed to get it to work, but when I access my home page its writing the following to the console:

(node:44714) [DEP0005] DeprecationWarning: Buffer() is deprecated due to security and usability issues. Please use the Buffer.alloc(), Buffer.allocUnsafe(), or Buffer.from() methods instead.
ERROR [Error]
ERROR [Error]

and each time I refresh the page it print ERROR [Error] again without any details, please note that I don't have any new Buffer() in my code, and I have followed the suggestions on stack overflow to solve this but no luck, can someone help to figure out what's causing this?


I have solved the ERROR [Error] by removing the TranslateService, but still having the deprecationWarning


回答1:


In case you're using Buffer() in your code just replace it with:

new Buffer(number) // Deprecated 
Buffer.alloc(number) // New

Or

new Buffer(string) // Deprecated 
Buffer.from(string) // New

In case you're not using Buffer() anywhere you have to do the following:

1) Search all of your app dependencies (You might use a tool for searching by clicking the search icon in the IDE your currently using and type Buffer())

2) Wherever you find a Buffer() in a module or dependency just replace it as mentioned above



来源:https://stackoverflow.com/questions/57063659/deprecationwarning-buffer-is-deprecated-due-to-security-and-usability-issues

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