I am new to TypeScript, Netlify, and RedwoodJS.
Yesterday I ran into a lot of problems trying to deploy what I thought was a simple RedwoodJS app without a database. (See How to fix graphql 404 on Netlify)
Possible to deploy without a database? looked like it would be helpful but actually:
- I did not need to delete the
api/prisma
directory - I did not comment out the contents of
api/src/lib/db.js
- In
netlify.toml
, I commented out the[[plugins]]
heading and everything underneath it. I also usedcommand = "yarn rw build"
under[build]
- At Netlify App, I changed Build command
toyarn workspaces run build
. I donβt understand how this relates to thenetlify.toml
setting or which takes precedence.
Then the other deployment error I was having was:
Deploy failed due to an error in @netlify/plugin-functions-core plugin.
Plugin β@netlify/plugin-functions-coreβ internal errorError: In file β/opt/build/repo/api/dist/functions/graphql.jsβ: Cannot find module β./platformCombiner.tsβ from β/opt/build/repo/api/dist/servicesβ
In βonBuildβ event in β@netlify/plugin-functions-coreβ from core at /opt/buildhome/.netlify-build-nvm/versions/node/v12.16.3/lib/node_modules/@netlify/build/node_modules/resolve/lib/async.js:142:35 at load (/opt/buildhome/.netlify-build-nvm/versions/node/v12.16.3/lib/node_modules/@netlify/build/node_modules/resolve/lib/async.js:161:43) at onex (/opt/buildhome/.netlify-build-nvm/versions/node/v12.16.3/lib/node_modules/@netlify/build/node_modules/resolve/lib/async.js:186:17) at /opt/buildhome/.netlify-build-nvm/versions/node/v12.16.3/lib/node_modules/@netlify/build/node_modules/resolve/lib/async.js:13:69 at FSReqCallback.oncomplete (fs.js:167:21)
Error properties: { code: βMODULE_NOT_FOUNDβ }
9:56:37 PM: ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
9:56:37 PM: β Plugin "@netlify/plugin-functions-core" internal error β
9:56:37 PM: ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
9:56:37 PM: β
9:56:37 PM: Error message
9:56:37 PM: Error: In file "/opt/build/repo/api/dist/functions/graphql.js": Cannot find module './platformCombiner.ts' from '/opt/build/repo/api/dist/services'
Here is what I figured out. Here are 3 attempts that each worked locally but then caused errors when trying to deploy to Netlify:
- api/src/services/orders.js had
import { combinePlatforms, decimalPlaces } from './platformCombiner.ts';
because I prefer splitting my code into small files - api/src/services/orders.ts had
import { combinePlatforms, decimalPlaces } from './platformCombiner.ts';
because I wondered if both files needed to be TypeScript, so I converted orders.js to orders.ts - I also tried moving platformCombiner.ts out to a separate directory called βhelpersβ (a sibling of the βservicesβ directory) so that platformCombiner.ts wouldnβt be considered its own service.
I figured out a workaround, but I donβt understand why this was necessary:
The workaround was merge platformCombiner.ts into orders.ts so that there was just one larger file.
Thanks for any ideas.
UPDATE: To clarify, the main part of my question is: Why was I not able to have my orders.ts service import platformCombiner.ts either in the same directory or in a sibling directory? Why did I need to merge platformCombiner.ts into orders.ts?