# Why my aes function now needs crypto module needed in new netlify version whereas it didn't in old

**URL:** <https://answers.netlify.com/t/why-my-aes-function-now-needs-crypto-module-needed-in-new-netlify-version-whereas-it-didnt-in-old/85976>\
**Category:** Support\
**Tags:** lambda-functions, netlify-newbie, deployment\
**Created:** [February 20, 2023, 12:26pm UTC](https://answers.netlify.com/t/why-my-aes-function-now-needs-crypto-module-needed-in-new-netlify-version-whereas-it-didnt-in-old/85976 "2023-02-20T12:26:29Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![lepinekong](https://sea1.discourse-cdn.com/netlify/user_avatar/answers.netlify.com/lepinekong/32/1035_2.png) [@lepinekong](https://answers.netlify.com/u/lepinekong)\
**Post date:** [February 20, 2023, 12:26pm UTC](https://answers.netlify.com/t/why-my-aes-function-now-needs-crypto-module-needed-in-new-netlify-version-whereas-it-didnt-in-old/85976/1 "2023-02-20T12:26:29Z")

</div>

nodejs now integrates crypto module natively, and my crypto function did work in old netlify site. I created a new site and now it failed to deploy. Isn’t this kind of regression ?

Failed during stage ‘building site’: Build script returned non-zero exit code: 2 ([Search results for '"non-zero exit code: 2"' - Netlify Support Forums](https://ntl.fyi/exit-code-2))  
1:01:52 PM: In file “/opt/build/repo/netlify/functions/aes-decrypt.js”  
1:01:52 PM: Cannot find module ‘crypto-js’  
1:01:52 PM: Require stack:  
1:01:52 PM: - /opt/buildhome/node-deps/node\_modules/@netlify/zip-it-and-ship-it/dist/runtimes/node/bundlers/zisi/resolve.js  
1:01:52 PM: ​  
1:01:52 PM: Resolved config  
1:01:52 PM: build:  
1:01:52 PM: publish: /opt/build/repo  
1:01:52 PM: publishOrigin: ui  
1:01:52 PM: functionsDirectory: /opt/build/repo/netlify/functions

---

<div class="post-metadata">

**Author:** ![clarnx](https://sea1.discourse-cdn.com/netlify/user_avatar/answers.netlify.com/clarnx/32/40777_2.png) [@clarnx](https://answers.netlify.com/u/clarnx)\
**Post date:** [February 21, 2023, 1:26pm UTC](https://answers.netlify.com/t/why-my-aes-function-now-needs-crypto-module-needed-in-new-netlify-version-whereas-it-didnt-in-old/85976/2 "2023-02-21T13:26:18Z")

</div>

> [@lepinekong](#):
>
> nodejs now integrates crypto module natively, and my crypto function did work in old netlify site. I created a new site and now it failed to deploy. Isn’t this kind of regression ?

You need to install module `crypto-js` neven if Nodejs now has a crypto module. It’s either you use the Native Node.js crypto API or you use the packages (crypto-js) API.  
The API of the Node.js crypto module and the `crypto-js` package are different.

Node.js Crypto Module:  
[https://nodejs.org/api/crypto.html](https://nodejs.org/api/crypto.html)

> [@lepinekong](#):
>
> 1:01:52 PM: Cannot find module ‘crypto-js’

Kindly visit the official npm page of the `crypto-js` package in the link below and then **install** and **configure**

> **[crypto-js](https://www.npmjs.com/package/crypto-js)**
>
> JavaScript library of crypto standards.. Latest version: 4.2.0, last published: a month ago. Start using crypto-js in your project by running \`npm i crypto-js\`. There are 10913 other projects in the npm registry using crypto-js.

Hope the above explanation and suggestion helps.

Thanks.
