Error deploying to Netlify: Cannot find module '../../../.redwood/datamodel.json'

Update on this, it was fixed and should go out in the last v1-rc before code freeze

3 Likes

do you have a link to PR I have ran into a similar issue

Which version of RW are you running, this fix should have gone out with the V1. Can you provide more info on your error so I can help you debug?

Redwood 2.0.0 and here is some of my dependencies

"dependencies": {

    "@redwoodjs/forms": "2.0.0",

    "@redwoodjs/router": "2.0.0",

    "@redwoodjs/web": "2.0.0",

    "filepond": "^4.30.4",

    "filepond-plugin-image-exif-orientation": "^1.0.11",

    "filepond-plugin-image-preview": "^4.6.11",

    "nodemailer": "^6.7.7",

    "nodemailer-plugin-inline-base64": "^2.1.1",

    "prop-types": "15.8.1",

    "react": "17.0.2",

    "react-dom": "17.0.2",

    "react-filepond": "^7.1.2"

  },

Basically I am following the Netlify tutorial on the Docs on Redwood and I follow steps

Like using railway for postgres
then yarn rw setup deploy netlify

after making edits in netlify.toml file

[build]
command = "yarn rw deploy netlify"
publish = "web/dist"
# [functions]
functions = "api/dist/functions"
# directory = "api/dist/functions"
# http://localhost:8910/.netlify/functions/graphql
  # Flags "package-1" as an external node module for all functions.
  # [functions.functions]
  # external_node_modules = [
  #   "api/dist/",
  #   "lib",
  #   "directives",
  #   "services",
  #   "graphql"
  #   ]
  # Includes all Markdown files inside the "files/" directory.
  # included_files = ["files/*.md"]
# included_files = ["api/dist/*.js"]
# included_files = ["api/dist/directives/*"]
# included_files = ["api/dist/graphql/*"]
# included_files = ["api/dist/lib/*"]
# included_files = ["api/dist/services/*"]
# [functions]
# directory = "api/dist/"
  # [functions.directory2]
  #   directory2 = "api/dist/lib"
[dev]
  # yarn rw build --verbose && yarn rw prisma migrate deploy && yarn rw data-migrate up
  # To use [Netlify Dev](https://www.netlify.com/products/dev/),
  # install netlify-cli from https://docs.netlify.com/cli/get-started/#installation
  # and then use netlify link https://docs.netlify.com/cli/get-started/#link-and-unlink-sites
  # to connect your local project to a site already on Netlify
  # then run netlify dev and our app will be accessible on the port specified below
  framework = "redwoodjs"
  # Set targetPort to the [web] side port as defined in redwood.toml
  targetPort = 8910
  # Point your browser to this port to access your RedwoodJS app
  port = 8888
[[redirects]]
  from = "/*"
  to = "/200.html"
  status = 200

However my netlify serverless functions gives we error accessible at this URL

What I figured out is the serverless function cannot located the ‘…\lib\auth’ library even the build file in dist does have that library and code available. What this means is that all my graphQL queries are failing all forms all to submit data etc

http://diamondhaulingpa.com/.netlify/functions/graphql

I have been looking for answer all day sunday came cross this old post it was the most similar. The logs on netlify serverless function are pretty much the same

Aug 9, 08:34:31 PM: 342bc5ac Duration: 2322.17 ms	Memory Usage: 91 MB	Aug 9, 08:34:31 PM: Unknown application error occurred
Runtime.ImportModuleError
Aug 9, 08:34:32 PM: 2022-08-10T00:34:32.218Z	undefined	ERROR	Uncaught Exception 	{"errorType":"Runtime.ImportModuleError","errorMessage":"Error: Cannot find module '..\\..\\lib\\auth'\nRequire stack:\n- /var/task/api/dist/directives/requireAuth/requireAuth.js\n- /var/task/api/dist/functions/graphql.js\n- /var/task/graphql.js\n- /var/runtime/index.mjs","stack":["Runtime.ImportModuleError: Error: Cannot find module '..\\..\\lib\\auth'","Require stack:","- /var/task/api/dist/directives/requireAuth/requireAuth.js","- /var/task/api/dist/functions/graphql.js","- /var/task/graphql.js","- /var/runtime/index.mjs","    at _loadUserApp (file:///var/runtime/index.mjs:726:17)","    at async Object.module.exports.load (file:///var/runtime/index.mjs:741:21)","    at async file:///var/runtime/index.mjs:781:15","    at async file:///var/runtime/index.mjs:4:1"]}
Aug 9, 08:34:32 PM: 5245799d Duration: 2251.47 ms	Memory Usage: 92 MB	Aug 9, 08:34:32 PM: Unknown application error occurred
Runtime.ImportModuleError
Aug 9, 08:34:33 PM: 2022-08-10T00:34:33.375Z	undefined	ERROR	Uncaught Exception 	{"errorType":"Runtime.ImportModuleError","errorMessage":"Error: Cannot find module '..\\..\\lib\\auth'\nRequire stack:\n- /var/task/api/dist/directives/requireAuth/requireAuth.js\n- /var/task/api/dist/functions/graphql.js\n- /var/task/graphql.js\n- /var/runtime/index.mjs","stack":["Runtime.ImportModuleError: Error: Cannot find module '..\\..\\lib\\auth'","Require stack:","- /var/task/api/dist/directives/requireAuth/requireAuth.js","- /var/task/api/dist/functions/graphql.js","- /var/task/graphql.js","- /var/runtime/index.mjs","    at _loadUserApp (file:///var/runtime/index.mjs:726:17)","    at async Object.module.exports.load (file:///var/runtime/index.mjs:741:21)","    at async file:///var/runtime/index.mjs:781:15","    at async file:///var/runtime/index.mjs:4:1"]}
Aug 9, 08:34:33 PM: f7ff3246 Duration: 2368.25 ms	Memory Usage: 97 MB	Aug 9, 08:34:33 PM: Unknown application error occurred
Runtime.ImportModuleError

What are the “files/*.md”? Does the api import from a files directory are the same level as the api ? Or is files inside api?

You may need to force those to get built on Netlify by injecting them into the zip it creates.

See Error deploying to Netlify: Cannot find module '../../../.redwood/datamodel.json'

And

Yes so the included files is supposed to import those files outside of directory and I tried that directly for each folder and files contained in each folder but this did not work or remove the error.

What do you mean by force do you have a specific command line you are referencing?

# included_files = ["api/dist/*.js"]
# included_files = ["api/dist/directives/*"]
# included_files = ["api/dist/graphql/*"]
# included_files = ["api/dist/lib/*"]
# included_files = ["api/dist/services/*"]