This function has crashed – TypeError - (0 , import_slicedToArray2.default) is not a function
Closed this issue · 3 comments
FYI: Originally started this thread in the Netlify Community: https://answers.netlify.com/t/remix-this-function-has-crashed-typeerror-0-import-slicedtoarray2-default-is-not-a-function/106308
Summary
I recently upgraded a Remix app I have deployed on Netlify from v1
to v2
by following the directions listed here:
- Netlify – Upgrading from Remix 1 to Remix 2: https://github.com/netlify/remix-compute/blob/main/docs/upgrading.md 1
- Remix – upgrading to v2: Upgrading to v2 | Remix
You can see my related PRs here:
- Upgrade to Remix v2: Upgraded to Remix
v2
by kevinreber · Pull Request #72 · kevinreber/ai-icon-generator · GitHub - Attempting to fix Netlify build: Hoping this fixes prod 🙏 by kevinreber · Pull Request #77 · kevinreber/ai-icon-generator · GitHub
References
- Remix – Netlify Deployed Site: https://icongenn.com/
- Github Rep: GitHub - kevinreber/ai-icon-generator: Generate images with the click of a button using Artificial Intelligence!
Looking at the logs it says my build is marked as “Complete”, but when I visit the deployed site I see the following message
This function has crashed
An unhandled error in the function code triggered the following message:
TypeError - (0 , import_slicedToArray2.default) is not a function
Stack trace
TypeError: (0 , import_slicedToArray2.default) is not a function
at setTwoToneColor (/var/task/.netlify/functions-internal/server.js:1490:128)
at Object.<anonymous> (/var/task/.netlify/functions-internal/server.js:1501:1)
at Module._compile (node:internal/modules/cjs/loader:1256:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1310:10)
at Module.load (node:internal/modules/cjs/loader:1119:32)
at Module._load (node:internal/modules/cjs/loader:960:12)
at Module.require (node:internal/modules/cjs/loader:1143:19)
at require (node:internal/modules/cjs/helpers:119:18)
at Object.<anonymous> (/var/task/server.js:1:18)
at Module._compile (node:internal/modules/cjs/loader:1256:14)
Connection details
Netlify internal ID: 01HEYB4Z9T4ZBRKC5GK7SRBZ0F
Build Logs
8:42:02 PM: Netlify Build
8:42:02 PM: ────────────────────────────────────────────────────────────────
8:42:02 PM:
8:42:02 PM: ❯ Version
8:42:02 PM: @netlify/build 29.26.3
8:42:02 PM:
8:42:02 PM: ❯ Flags
8:42:02 PM: baseRelDir: true
8:42:02 PM: buildId: 654f05f6e88e2e000862a54e
8:42:02 PM: deployId: 654f05f6e88e2e000862a550
8:42:02 PM:
8:42:02 PM: ❯ Current directory
8:42:02 PM: /opt/build/repo
8:42:02 PM:
8:42:02 PM: ❯ Config file
8:42:02 PM: /opt/build/repo/netlify.toml
8:42:02 PM:
8:42:02 PM: ❯ Context
8:42:02 PM: production
8:42:02 PM:
8:42:02 PM: build.command from netlify.toml
8:42:02 PM: ────────────────────────────────────────────────────────────────
8:42:02 PM:
8:42:02 PM: $ remix build
8:42:02 PM: info building... (NODE_ENV=production)
8:42:05 PM: info built (2.7s)
8:42:05 PM:
8:42:05 PM: (build.command completed in 3.2s)
8:42:05 PM:
8:42:05 PM: Functions bundling
8:42:05 PM: ────────────────────────────────────────────────────────────────
8:42:05 PM:
8:42:05 PM: Packaging Functions from .netlify/functions-internal directory:
8:42:05 PM: - server.js
8:42:05 PM:
8:42:12 PM:
8:42:12 PM: (Functions bundling completed in 7.1s)
8:42:12 PM:
8:42:20 PM: (Netlify Build completed in 17.9s)
8:42:25 PM: Section completed: building
8:42:33 PM: Finished processing build request in 1m5.639s
Files setup
netlify.toml
[build]
command = "remix build"
publish = "public"
[dev]
command = "remix watch"
port = 3000
[[redirects]]
from = "/*"
to = "/.netlify/functions/server"
status = 200
[[headers]]
for = "/build/*"
[headers.values]
"Cache-Control" = "public, max-age=31536000, s-maxage=31536000"
package.json
{
"private": true,
"sideEffects": false,
"type": "module",
"scripts": {
"build": "remix build",
"dev": "yarn run check-env-file && remix dev",
"start": "netlify dev",
"typecheck": "tsc",
"check-env-file": "node ./scripts/check-env-file.mjs",
"postinstall": "prisma generate",
"stripe:listen": "stripe listen --forward-to localhost:3000/webhook",
"format": "prettier --write .",
"lint": "eslint --cache --cache-location ./node_modules/.cache/eslint ."
},
"dependencies": {
"@ant-design/colors": "^7.0.0",
"@ant-design/icons": "^5.0.1",
"@aws-sdk/client-s3": "^3.363.0",
"@netlify/functions": "^2.3.0",
"@netlify/remix-adapter": "^2.2.0",
"@prisma/client": "^4.13.0",
"@remix-run/css-bundle": "^2.2.0",
"@remix-run/express": "^2.2.0",
"@remix-run/node": "2.2.0",
"@remix-run/react": "2.2.0",
"antd": "4.24.10",
"cross-env": "^7.0.3",
"dotenv": "^16.0.3",
"isbot": "^3.6.8",
"moment": "^2.29.4",
"openai": "^3.2.1",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"remix-auth": "^3.6.0",
"remix-auth-socials": "^2.0.5",
"stripe": "^12.3.0"
},
"devDependencies": {
"@remix-run/dev": "2.2.0",
"@remix-run/eslint-config": "2.2.0",
"@remix-run/serve": "2.2.0",
"@types/eslint": "^8.44.3",
"@types/react": "^18.0.35",
"@types/react-dom": "^18.0.11",
"eslint": "^8.38.0",
"eslint-config-airbnb": "^19.0.4",
"eslint-config-prettier": "^9.0.0",
"prettier": "^3.0.3",
"prisma": "^4.13.0",
"tailwindcss": "^3.3.3",
"typescript": "^4.9.5",
"zx": "7.0.8"
},
"engines": {
"node": "20.5.0"
}
}
remix.config.js
/** @type {import('@remix-run/dev').AppConfig} */
import { config } from "@netlify/remix-adapter";
export default {
...config,
serverDependenciesToBundle: [
"@ant-design/icons",
/^@ant-design\/icons-svg.*/,
/^rc-util.*/,
],
serverModuleFormat: "cjs",
};
This is not fixed yet ? I ended up with the same error. I tried to deploy a freshly created netlify vite template.
This is not fixed yet ? I ended up with the same error. I tried to deploy a freshly created netlify vite template.
i also faced the same issue wi passport js function.. any solution please
@kevinreber We're sorry you never got a response here. I hope you were able to resolve your issue. Since this is quite old, I'm going to close it. @mbsyaswanth @malik991 Please feel free to open new issues or (even better) post at https://answers.netlify.com/ if you're still having issues.