When running my app (just a node backend), I get `Cannot find module 'cors'` error.
The cors package is listed in my package.json dependencies, the npm install step seems to run fine too.
And yet it can't seem to find the cors module.
this is my app.yml
```
runtime: nodejs20
env: standard
handlers:
- url: /.*
script: auto
```
I've tried finding a way to see what's in the modules with no success. Iv'e tried different node version, and re-running npm install on build / start, but nothing works.
I've deployed other apps on app engine (full stack apps) and never had this error
Hi @Lightwaves,
I would like to confirm if your app is running behind Identity Aware Proxy (IAP)? If it is, it might be throwing errors because IAP has CORS disabled by default. You may refer to this document on how to enable CORS when using App Engine with IAP.
On the other hand, the "Cannot find module 'cors'" error usually happens when the cors module isn't being recognized, even though it's in your package.json. Since you've already checked that the npm install runs without errors, there are a few things we can try:
rm -rf node_modules
npm install
gcloud app deploy
npm ls cors
Once you confirm if the Cors package is in your node_modules. You can try to install/reinstall by running the code:npm uninstall cors
npm install cors
runtime: nodejs20
env: standard
env_variables:
NODE_ENV: 'production'
handlers:
- url: /.*
script: auto
After doing this, try redeploying to App Engine and see if that clears things up. If the above solution doesn't resolve the issue, you can contact Google Cloud Support to further look into your case. I can't say exactly a specific time frame, but they'll do their best to address the issue. Let me know if it helped, thanks!