Netlify deployment error: Cannot find module

I’m trying to deploy my project to Netlify but face the below error. The error seems to happen when Netlify tries to package the server-side code. Is this error related to redwoodjs or is it a Netlify issue?

The code repo is here: GitHub - vidalab/vida: Flexible data viz using redwoodjs framework

Error happens here: vida/vizjson.js at master · vidalab/vida · GitHub


5:20:09 PM: All migrations are already applied
5:20:09 PM: Migrate database up... [completed]
5:20:09 PM: Done in 2.89s.
5:20:09 PM: yarn run v1.17.0
5:20:09 PM: $ /opt/build/repo/node_modules/.bin/rw build
5:20:10 PM: Generating the Prisma client... [started]
5:20:14 PM: Generating the Prisma client... [completed]
5:20:14 PM: [00:20:14] Building "api"... [started]
5:20:16 PM: [00:20:16] Building "api"... [completed]
5:20:16 PM: [00:20:16] Building "web"... [started]
5:20:50 PM: [00:20:50] Building "web"... [completed]
5:20:50 PM: Done in 41.00s.
5:20:50 PM: Function Dir: /opt/build/repo/api/dist/functions
5:20:50 PM: TempDir: /tmp/zisi-5ea8c7fab5370a01945ae902
5:20:51 PM: Prepping functions with zip-it-and-ship-it 0.3.1
5:20:51 PM: Error: Cannot find module '../viz/viz.json' from '/opt/build/repo/api/dist/services'
5:20:51 PM: Error prepping functions
5:20:51 PM: Error running command: Build script returned non-zero exit code: 1
5:20:51 PM: Failing build: Failed to build site
5:20:51 PM: failed during stage 'building site': Build script returned non-zero exit code: 1
5:20:52 PM: Finished processing build request in 1m43.360688341s

Hi @dnprock I think the issue here is the location of the /viz directory. The Netlify deploy is configured to build and deploy functions via Netlify Lambdas, which does not include static files. You can emulate the Netlify build and deploy process locally via this doc. Zip it and Ship it handles the Lambda functions.

I think you’d be best off moving the files from viz/ into web/public. Here’s our document on handling assets and files. However, then you’ll be in a strange situation where the Lamba functions are loading data from your static files deployed on Netlify’s CDN. This might work but, honestly, I’m not sure. You probably don’t need an API for this app, as it seems you could move all the logic in vizjson.js into web/.

(Another idea could be to store them in AWS S3 or other cloud storage. But they are very small files and should be fine to deploy with web/.)

Lastly, because you’re not using a DB (and you might not even use an API), you’ll need to modify the Netlify build and deploy scripts further. (Currently, the scripts will always try to build Prisma DB Connection and fail if they can’t.) Here’s a forum topic with an example for deploying without DB. If you decide to deploy without an API, you’ll just need to update the netlify.toml to only build the web and not handle functions.

Keep me posted! And let me know if you have any further questions.

@thedavid thanks, I’m trying to remove the db dependency. Got an error. I post it in the db thread.

One other random’ish idea for you regarding: “Where to ‘host’ the .json files?”

You could host them in a GitHub repo (private or public) and access using the GitHub api, which would make use of the API.


This might be of help:

@thedavid thanks. I switch to using we/public folder. It’s working well locally. I got passed disable db step. Now Netlify is throwing me a 502 error. Any suggestion to fix this?

The Function log error is:

1:43:54 PM: 2020-04-29T20:43:54.837Z undefined ERROR Uncaught Exception {“errorType”:“Runtime.ImportModuleError”,“errorMessage”:“Error: Cannot find module ‘@babel/runtime-corejs3/helpers/interopRequireWildcard’\nRequire stack:\n- /var/task/graphql.js\n- /var/runtime/UserFunction.js\n- /var/runtime/index.js”,“stack”:[“Runtime.ImportModuleError: Error: Cannot find module ‘@babel/runtime-corejs3/helpers/interopRequireWildcard’”,“Require stack:”,"- /var/task/graphql.js","- /var/runtime/UserFunction.js","- /var/runtime/index.js"," at _loadUserApp (/var/runtime/UserFunction.js:100:13)"," at Object.module.exports.load (/var/runtime/UserFunction.js:140:17)"," at Object. (/var/runtime/index.js:43:30)"," at Module._compile (internal/modules/cjs/loader.js:1158:30)"," at Object.Module._extensions…js (internal/modules/cjs/loader.js:1178:10)"," at Module.load (internal/modules/cjs/loader.js:1002:32)"," at Function.Module._load (internal/modules/cjs/loader.js:901:14)"," at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:74:12)"," at internal/main/run_main_module.js:18:47"]}

I went back and use a heroku postgres deployment. I got my app to work on Netlify now. We plan to use a db in the future anyway.


1 Like