thin-backend icon indicating copy to clipboard operation
thin-backend copied to clipboard

Vercel `npm run build` errors on types

Open jokull opened this issue 2 years ago • 4 comments

[15:41:37.616] Cloning github.com/jokull/vercel-thin-test (Branch: main, Commit: c20d830)
[15:41:37.962] Cloning completed: 345.359ms
[15:41:38.352] Installing build runtime...
[15:41:41.831] Build runtime installed: 3.478s
[15:41:42.635] Looking up build cache...
[15:41:46.138] Build cache downloaded [50.11 MB]: 3140.970ms
[15:41:46.420] Detected `package-lock.json` generated by npm 7...
[15:41:52.284] 
[15:41:52.284] added 39 packages, removed 227 packages, and changed 5 packages in 6s
[15:41:52.285] 
[15:41:52.285] 76 packages are looking for funding
[15:41:52.285]   run `npm fund` for details
[15:41:52.302] Detected Next.js version: 12.1.5
[15:41:52.306] Detected `package-lock.json` generated by npm 7...
[15:41:52.306] Running "npm run build"
[15:41:52.698] 
[15:41:52.698] > [email protected] build
[15:41:52.698] > next build
[15:41:52.698] 
[15:41:53.303] info  - Loaded env from /vercel/path0/.env
[15:41:53.568] info  - Checking validity of types...
[15:41:56.940] Failed to compile.
[15:41:56.940] 
[15:41:56.941] ./pages/index.tsx:97:26
[15:41:56.941] Type error: Argument of type '"posts"' is not assignable to parameter of type 'TableName'.
[15:41:56.941] 
[15:41:56.941] [0m [90m  95 | [39m[0m
[15:41:56.941] [0m [90m  96 | [39m    onSubmit[33m:[39m async (fieldValues) [33m=>[39m {[0m
[15:41:56.941] [0m[31m[1m>[22m[39m[90m  97 | [39m      await createRecord([32m"posts"[39m[33m,[39m {[0m
[15:41:56.941] [0m [90m     | [39m                         [31m[1m^[22m[39m[0m
[15:41:56.942] [0m [90m  98 | [39m        title[33m:[39m fieldValues[33m.[39mtitle[33m,[39m[0m
[15:41:56.942] [0m [90m  99 | [39m        content[33m:[39m fieldValues[33m.[39mcontent[33m,[39m[0m
[15:41:56.942] [0m [90m 100 | [39m      })[33m;[39m[0m
[15:41:56.965] Error: Command "npm run build" exited with 1

My packages.json:

{
  "name": "ihp-backend-next-typescript-starter",
  "version": "0.1.0",
  "private": true,
  "scripts": {
    "dev": "next dev",
    "build": "next build",
    "start": "next start",
    "lint": "next lint"
  },
  "dependencies": {
    "@heroicons/react": "^1.0.6",
    "@shopify/react-form": "^1.1.19",
    "next": "^12.1.5",
    "react": "17.0.2",
    "react-dom": "17.0.2",
    "thin-backend": "*"
  },
  "devDependencies": {
    "@tailwindcss/forms": "^0.5.0",
    "@types/node": "^17.0.29",
    "@types/react": "17.0.37",
    "@types/thin-backend": "https://thin.dev/ShowTypescriptDeclarationFile?typescriptDeclarationFileId=d7540d89-7a5e-468a-82d2-be573b79dab9&accessToken=KJAkmygLwbMGCrLidrTAAJMZIBNefmoF",
    "autoprefixer": "^10.4.5",
    "eslint": "8.5.0",
    "eslint-config-next": "12.0.7",
    "postcss": "^8.4.12",
    "tailwindcss": "^3.0.24",
    "typescript": "4.5.4"
  }
}

jokull avatar Apr 28 '22 15:04 jokull

Hm, I cannot reproduce this issue with your project with a clean checkout. It seems like your project is using an outdated @types/thin-backend module. Maybe a npm install can fix it?

Otherwise open the Schema Designer -> Type Definitions and re-run the latest command there:

image

mpscholten avatar Apr 28 '22 15:04 mpscholten

It worked, but only after doing Redeploy without the build cache on Vercel. I think maybe Vercel doesn't have a way to invalidate the cache based on package-lock.json if there are this kind of dynamic dependencies?

jokull avatar Apr 28 '22 17:04 jokull

Oh that's strange. I would expect vercel to detect changes to package.json and package-lock.json and automatically invalidate it.

mpscholten avatar Apr 28 '22 17:04 mpscholten

Might be https://github.com/vercel/next.js/discussions/33929#discussioncomment-2295926

mpscholten avatar Apr 28 '22 17:04 mpscholten