Got error while trying to host on Netlify and on rpm run build
kaushikkamal opened this issue · 1 comments
Hi
I got error when I tried to host my project on Netlify.
error during build:
6:49:18 PM: SyntaxError: Unexpected token (26:17183) in /opt/build/repo/node_modules/vis-data/peer/umd/vis-data.min.js
6:49:18 PM: at pp$4.raise (file:///opt/build/repo/node_modules/rollup/dist/es/shared/node-entry.js:21435:13)
6:49:18 PM: at pp$9.unexpected (file:///opt/build/repo/node_modules/rollup/dist/es/shared/node-entry.js:18643:8)
6:49:18 PM: at pp$5.parseIdentNode (file:///opt/build/repo/node_modules/rollup/dist/es/shared/node-entry.js:21371:10)
6:49:18 PM: at pp$5.parseIdent (file:///opt/build/repo/node_modules/rollup/dist/es/shared/node-entry.js:21344:19)
6:49:18 PM: at pp$5.parsePropertyName (file:///opt/build/repo/node_modules/rollup/dist/es/shared/node-entry.js:21163:109)
6:49:18 PM: at pp$5.parseProperty (file:///opt/build/repo/node_modules/rollup/dist/es/shared/node-entry.js:21086:8)
6:49:18 PM: at pp$5.parseObj (file:///opt/build/repo/node_modules/rollup/dist/es/shared/node-entry.js:21049:21)
6:49:18 PM: at pp$5.parseExprAtom (file:///opt/build/repo/node_modules/rollup/dist/es/shared/node-entry.js:20775:17)
6:49:18 PM: at pp$5.parseExprSubscripts (file:///opt/build/repo/node_modules/rollup/dist/es/shared/node-entry.js:20583:19)
6:49:18 PM: at pp$5.parseMaybeUnary (file:///opt/build/repo/node_modules/rollup/dist/es/shared/node-entry.js:20549:17)
6:49:18 PM:
6:49:18 PM: build.command failed
6:49:18 PM: Error message
6:49:18 PM: Command failed with exit code 1: CI= npm run build (https://ntl.fyi/exit-code-1)
6:49:18 PM:
6:49:18 PM: Error location
6:49:18 PM: In Build command from Netlify app:
6:49:18 PM: CI= npm run build
6:49:18 PM:
6:49:18 PM: Resolved config
6:49:18 PM: build:
6:49:18 PM: command: CI= npm run build
6:49:18 PM: commandOrigin: ui
6:49:18 PM: publish: /opt/build/repo/dist
6:49:18 PM: publishOrigin: ui
6:49:20 PM: Build failed due to a user error: Build script returned non-zero exit code: 2
6:49:20 PM: Failing build: Failed to build site
6:49:20 PM: Finished processing build request in 24.511s
Node version: v18.15.0
package.json
{
"name": "graph-vizualization",
"private": true,
"version": "0.0.0",
"type": "module",
"scripts": {
"dev": "vite",
"build": "tsc && vite build",
"lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
"preview": "vite preview"
},
"dependencies": {
"@reduxjs/toolkit": "^1.9.5",
"@types/vis": "^4.21.24",
"ace-builds": "^1.23.4",
"html2canvas": "^1.4.1",
"react": "^18.2.0",
"react-ace": "^10.1.0",
"react-dom": "^18.2.0",
"react-graph-vis": "^1.0.7",
"react-icons": "^4.10.1",
"react-redux": "^8.1.1",
"sass": "^1.64.1"
},
"devDependencies": {
"@types/react": "^18.2.15",
"@types/react-dom": "^18.2.7",
"@typescript-eslint/eslint-plugin": "^6.0.0",
"@typescript-eslint/parser": "^6.0.0",
"@vitejs/plugin-react": "^4.0.3",
"eslint": "^8.45.0",
"eslint-plugin-react-hooks": "^4.6.0",
"eslint-plugin-react-refresh": "^0.4.3",
"typescript": "^5.0.2",
"vite": "^4.4.5"
}
}
For the Build command in Netlify, I have tried with CI= npm run build and npm run build , but did not work
vite.config.ts
export default defineConfig({
plugins: [react()],
define: {
global: {}, // Have to use this, otherwise gave Uncaught ReferenceError: global is not defined
},
});
Locally it works fine. Any suggestion on this
Thanks in advance 🤝
I am able to resolve the issue by switching from Vite to Create-React-App