Why Ant Design CSS looks different on deployment than in development - css

I am currently working on a project where we agreed to use Ant Design library with NextJS and TypeScript
When I test locally using npm run dev everything looks alright, but on npm run build and npm run start the css looks a complete mess.
I tried overriding Ant Design default css using the !important property on various of different classes but I don't think that's a very good approach. Has anyone ever encountered such a problem before?
Here is the package.json file if that's relevant
{
"scripts": {
"dev": "next dev",
"build": "next build",
"start": "next start",
"lint": "eslint src --ext js,ts,tsx",
"test": "jest --config ./configs/jest.config.js",
"prepare": "husky install"
},
"dependencies": {
"#ant-design/icons": "^4.7.0",
"antd": "^4.18.6",
"axios": "^0.25.0",
"next": "^12.1.0",
"react": "17.0.2",
"react-dom": "17.0.2"
},
"devDependencies": {
"#testing-library/jest-dom": "^5.16.1",
"#testing-library/react": "^12.1.2",
"#types/node": "17.0.12",
"#types/react": "17.0.38",
"babel-jest": "^27.4.6",
"concurrently": "^7.0.0",
"eslint": "8.7.0",
"eslint-config-next": "12.0.8",
"eslint-config-prettier": "^8.3.0",
"eslint-config-ts-react-important-stuff": "^3.0.0",
"eslint-plugin-prettier": "^4.0.0",
"husky": "^7.0.4",
"jest": "^27.4.7",
"jest-css-modules": "^2.1.0",
"pretty-quick": "^3.1.3",
"typescript": "^4.5.5"
}
}

Related

.less files are not appear in Nuxt 3 build

I have a nuxt 3 app, where i want to set global styles via .less files.
nuxt.config.ts
css: [
"#/assets/less/main.less"
],
If i run yarn run dev everything works fine, but when i run
yarn run build (nuxt build) and yarn run preview(nuxt preview) the .less files are just not there. For some reason the build doesnt contain any of the styles from the .less files.
I tried to add the less-loader package (although as i know its not needed in nuxt3).
I guess the problem is around the difference of NODE_ENV production / develop,but im not sure how or what should i config to get the build involve the .less files.
here is my package.json
{
"private": true,
"scripts": {
"build": "nuxt build",
"dev": "nuxt dev",
"generate": "nuxt generate",
"preview": "nuxt preview",
"postinstall": "nuxt prepare",
"analyze": "nuxt analyze",
"cleanup": "nuxt cleanup"
},
"devDependencies": {
"#nuxtjs/eslint-config": "^11.0.0",
"#nuxtjs/eslint-config-typescript": "^11.0.0",
"#popperjs/core": "^2.11.6",
"bootstrap": "^5.2.2",
"dayjs": "^1.11.5",
"eslint": "^8.24.0",
"less": "^4.1.3",
"less-loader": "^11.1.0",
"line-clamp": "^1.0.0",
"nuxt": "3.0.0-rc.10",
"vue": "^3.2.40"
},
"dependencies": {
"#microsoft/signalr": "^7.0.0",
"bootstrap-vue-3": "0.4.13",
"mitt": "^3.0.0",
"vue-disqus": "^5.1.0",
"vue-gtag": "^2.0.1",
"vue-next-masonry": "1.1.3",
"vue-tweet": "^2.0.2"
}
}

"Error: Hook can only be invoked from render methods." error in Next.js and Preact

I am a beginner in Next.js. In Next.js and Preact based application, after downloading "node_modules" with "npm install --legacy-peer-deps" and running the project with "npm run dev", I am getting errors that I will add below. On the Homepage, I see the text "Internal Server Error".
I tried many versions of "Node.js" with "nvm" as a solution. When I worked on LTS and latest version the project never worked. When I run it on 16.x.x and below, the project works but errors occur.
I couldn't find the cause and solution for this. I hope someone knows the solution.
Errors:
Error: Hook can only be invoked from render methods.
at Object.n.options.__h (C:\Users\muham\OneDrive\Masaüstü\WESTEROPS\neom-hotel-nextjs\node_modules\preact\debug\dist\debug.js:1:6026)
at l (C:\Users\muham\OneDrive\Masaüstü\WESTEROPS\neom-hotel-nextjs\node_modules\preact\hooks\dist\hooks.js:1:175)
at Object.m (C:\Users\muham\OneDrive\Masaüstü\WESTEROPS\neom-hotel-nextjs\node_modules\preact\hooks\dist\hooks.js:1:335)
at ReactDevOverlay (C:\Users\muham\OneDrive\Masaüstü\WESTEROPS\neom-hotel-nextjs\node_modules\#next\react-dev-overlay\lib\internal\ReactDevOverlay.js:87:27)
at ReactDevOverlay (C:\Users\muham\OneDrive\Masaüstü\WESTEROPS\neom-hotel-nextjs\node_modules\next\dist\server\dev\next-dev-server.js:71:12) at renderWithHooks (C:\Users\muham\OneDrive\Masaüstü\WESTEROPS\neom-hotel-nextjs\node_modules\react-dom\cjs\react-dom-server-legacy.node.development.js:5662:16)
at renderIndeterminateComponent (C:\Users\muham\OneDrive\Masaüstü\WESTEROPS\neom-hotel-nextjs\node_modules\react-dom\cjs\react-dom-server-legacy.node.development.js:5735:15)
at renderElement (C:\Users\muham\OneDrive\Masaüstü\WESTEROPS\neom-hotel-nextjs\node_modules\react-dom\cjs\react-dom-server-legacy.node.development.js:5950:7)
at renderNodeDestructiveImpl (C:\Users\muham\OneDrive\Masaüstü\WESTEROPS\neom-hotel-nextjs\node_modules\react-dom\cjs\react-dom-server-legacy.node.development.js:6108:11)
at renderNodeDestructive (C:\Users\muham\OneDrive\Masaüstü\WESTEROPS\neom-hotel-nextjs\node_modules\react-dom\cjs\react-dom-server-legacy.node.development.js:6080:14)
TypeError: Cannot read property 'context' of undefined
at Object.exports.useContext (C:\Users\muham\OneDrive\Masaüstü\WESTEROPS\neom-hotel-nextjs\node_modules\preact\hooks\dist\hooks.js:1:2697)
at useRouter (C:\Users\muham\OneDrive\Masaüstü\WESTEROPS\neom-hotel-nextjs\node_modules\next\dist\client\router.js:123:27)
at MyApp (C:\Users\muham\OneDrive\Masaüstü\WESTEROPS\neom-hotel-nextjs\.next\server\pages\_app.js:91:72)
at renderWithHooks (C:\Users\muham\OneDrive\Masaüstü\WESTEROPS\neom-hotel-nextjs\node_modules\react-dom\cjs\react-dom-server-legacy.node.development.js:5662:16)
at renderIndeterminateComponent (C:\Users\muham\OneDrive\Masaüstü\WESTEROPS\neom-hotel-nextjs\node_modules\react-dom\cjs\react-dom-server-legacy.node.development.js:5735:15)
at renderElement (C:\Users\muham\OneDrive\Masaüstü\WESTEROPS\neom-hotel-nextjs\node_modules\react-dom\cjs\react-dom-server-legacy.node.development.js:5950:7)
at renderNodeDestructiveImpl (C:\Users\muham\OneDrive\Masaüstü\WESTEROPS\neom-hotel-nextjs\node_modules\react-dom\cjs\react-dom-server-legacy.node.development.js:6108:11)
at renderNodeDestructive (C:\Users\muham\OneDrive\Masaüstü\WESTEROPS\neom-hotel-nextjs\node_modules\react-dom\cjs\react-dom-server-legacy.node.development.js:6080:14)
at renderIndeterminateComponent (C:\Users\muham\OneDrive\Masaüstü\WESTEROPS\neom-hotel-nextjs\node_modules\react-dom\cjs\react-dom-server-legacy.node.development.js:5789:7)
at renderElement (C:\Users\muham\OneDrive\Masaüstü\WESTEROPS\neom-hotel-nextjs\node_modules\react-dom\cjs\react-dom-server-legacy.node.development.js:5950:7)
package.json
{
"name": "neom-hotel-nextjs",
"version": "0.1.0",
"private": true,
"scripts": {
"dev": "next dev",
"build": "next build",
"export": "next build && next export",
"export-s3": "next build && next export '/*'",
"deploy": "next build && next export && firebase deploy",
"openid": "next build && next export && firebase hosting:channel:deploy openid",
"image": "next build && next export && firebase hosting:channel:deploy image",
"start": "next start",
"lint": "next lint"
},
"dependencies": {
"#fontsource/outfit": "^4.5.8",
"#steveeeie/react-page-transition": "^1.3.0",
"cupertino-pane": "^1.3.0",
"framer-motion": "^6.4.2",
"framework7-react": "^6.3.17",
"framework7": "^6.3.17",
"framework7-icons": "^4.0.2",
"imagemin-gifsicle": "^7.0.0",
"imagemin-mozjpeg": "^9.0.0",
"imagemin-optipng": "^8.0.0",
"mapbox-gl": "^2.9.1",
"next": "^11.1.4",
"next-compose-plugins": "^2.2.1",
"next-optimized-images": "^2.6.2",
"next-plugin-preact": "^3.0.7",
"preact": "^10.8.2",
"preact-render-to-string": "^5.2.0",
"react": "npm:#preact/compat",
"react-bottom-sheet": "^1.1.1",
"react-dom": "npm:#preact/compat",
"react-modal-sheet": "^1.5.2",
"react-scroll-hooks": "^0.1.1",
"react-ssr-prepass": "npm:preact-ssr-prepass",
"react-transition-group": "^4.4.2",
"responsive-loader": "^3.0.4",
"sharp": "latest",
"styled-components": "^5.3.5",
"url-loader": "^4.1.1",
"webp-loader": "^0.6.0"
},
"devDependencies": {
"#zeit/next-css": "^1.0.1",
"eslint": "8.18.0",
"eslint-config-next": "12.2.0",
"next-purgecss": "^4.0.0"
}
}
package-lock.json
{
"name": "neom-hotel-nextjs",
"version": "0.1.0",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "neom-hotel-nextjs",
"version": "0.1.0",
"dependencies": {
"#fontsource/outfit": "^4.5.8",
"#steveeeie/react-page-transition": "^1.3.0",
"cupertino-pane": "^1.3.0",
"framer-motion": "^6.4.2",
"framework7": "^6.3.17",
"framework7-icons": "^4.0.2",
"framework7-react": "^6.3.17",
"imagemin-gifsicle": "^7.0.0",
"imagemin-mozjpeg": "^9.0.0",
"imagemin-optipng": "^8.0.0",
"mapbox-gl": "^2.9.1",
"next": "^11.1.4",
"next-compose-plugins": "^2.2.1",
"next-optimized-images": "^2.6.2",
"next-plugin-preact": "^3.0.7",
"preact": "^10.8.2",
"preact-render-to-string": "^5.2.0",
"react": "npm:#preact/compat",
"react-bottom-sheet": "^1.1.1",
"react-dom": "npm:#preact/compat",
"react-modal-sheet": "^1.5.2",
"react-scroll-hooks": "^0.1.1",
"react-ssr-prepass": "npm:preact-ssr-prepass",
"react-transition-group": "^4.4.2",
"responsive-loader": "^3.0.4",
"sharp": "latest",
"styled-components": "^5.3.5",
"url-loader": "^4.1.1",
"webp-loader": "^0.6.0"
},
"devDependencies": {
"#zeit/next-css": "^1.0.1",
"eslint": "8.18.0",
"eslint-config-next": "12.2.0",
"next-purgecss": "^4.0.0"
}
},

Strange vue warn: `beforeDestroy` has been renamed to `beforeUnmount`

Well, I have this warning in the browser console:
[Vue warn]: `beforeDestroy` has been renamed to `beforeUnmount`.
at
This is weird, because I have not beforeDestroy anywhere and I have the latest versions of the packages in my package.json:
"scripts": {
"serve": "vue-cli-service serve",
"build": "vue-cli-service build",
"lint": "vue-cli-service lint"
},
"dependencies": {
"axios": "^0.21.1",
"core-js": "^3.6.5",
"moment": "^2.29.1",
"quill": "^1.3.7",
"register-service-worker": "^1.7.1",
"socket.io-client": "^3.1.0",
"three": "^0.123.0",
"uuid": "^3.4.0",
"v-calendar": "^3.0.0-alpha.3",
"vue": "^3.0.5",
"vue-dk-toast": "^1.3.3",
"vue-material-design-icons": "^4.11.0",
"vue-router": "^4.0.4",
"vue-socket.io": "^3.0.10",
"vue-uuid": "^2.0.2",
"vue3-carousel": "^0.1.11",
"vue3-quill": "^0.2.1",
"vuex": "^4.0.0-0"
},
"devDependencies": {
"#babel/core": "^7.12.17",
"#babel/eslint-parser": "^7.12.1",
"#vue/cli-plugin-babel": "^4.5.10",
"#vue/cli-plugin-eslint": "^4.5.10",
"#vue/cli-plugin-pwa": "^4.5.11",
"#vue/cli-plugin-router": "^4.5.11",
"#vue/cli-plugin-vuex": "~4.5.0",
"#vue/cli-service": "^4.5.11",
"#vue/compiler-sfc": "^3.0.5",
"#vue/eslint-config-airbnb": "^5.0.2",
"eslint": "^6.8.0",
"eslint-plugin-import": "^2.22.1",
"eslint-plugin-vue": "^7.6.0"
}
What could be wrong? I searched for the same problem but I only found this: https://github.com/ckeditor/ckeditor5/issues/8224 , which doesn't help.
Thanks in advance for your help.
I had a similar problem. I figured its because vue-socket.io is not compatible with Vue3. Below is my solution.
update to vue-3-socket.io, which is a Vue 3 compatibility version of vue-socket.io (though it still not perfectly compatible with Vue3)
then open the file node_modules/vue-3-socket.io/dist/vue-socketio.js
search for beforeDestroy and replace it with beforeUnmount
The fact that you have "all packages at highest version" is very different from "all the packages I'm using are compatible with Vue 3" ....its clear one of the packages is definitely NOT compatible with Vue 3...

Error: The `revalidate` property is not yet available for general use

My package.json file is
{
"name": "learn-starter",
"version": "0.1.0",
"private": true,
"scripts": {
"dev": "next dev",
"build": "next build",
"start": "next start",
"export": "next export"
},
"dependencies": {
"#tailwindcss/typography": "^0.2.0",
"date-fns": "^2.16.1",
"geolib": "^3.3.1",
"google-map-react": "^2.1.3",
"graphql": "^15.3.0",
"graphql-request": "3.0.0",
"gray-matter": "^4.0.2",
"isomorphic-unfetch": "^3.0.0",
"libphonenumber-js": "^1.7.57",
"next": "9.3.5",
"next-seo": "^4.7.3",
"react": "16.13.1",
"react-animated-css": "^1.2.1",
"react-dom": "16.13.1",
"react-gtm-module": "^2.0.11",
"react-static-google-map": "^0.6.2",
"remark": "^12.0.1",
"remark-html": "^12.0.0",
"tailwindcss": "^1.7.6",
"use-position": "^0.0.7"
},
"devDependencies": {}
}
I am trying to use revaildate: 1 in getStaticProps but I am getting error saying
Error: The `revalidate` property is not yet available for general use.
To try the experimental implementation, please use `unstable_revalidate` instead.
As I can see in package.json file my nextjs version is 9.3.5
Can anyone help me what I should do to fix this.
Try using "unstable_revalidate" instead of "revalidate", because in nextjs version <9.5, "revalidate" keyword is not yet generalised.

Error! You've attempted to require '#react-native-firebase/auth' version '6.2.0', however

Error! You've attempted to require #react-native-firebase/auth version '6.2.0', however, the #react-native-firebase/app module is of a different version (6.3.4).
I get this error whenever I launch the app. I've tried to reinstall all the modules, to delete and reinstall, to install all react native firebase modules to version 6.3.4, to version 6.2.0 but still nothing.
I can't use the firebase package because I've implemented firebase differently.
Do you have any idea what should I do?
Package.json:
"name": "Vanto",
"version": "0.0.1",
"private": true,
"scripts": {
"android": "react-native run-android",
"ios": "react-native run-ios",
"start": "react-native start",
"test": "jest",
"lint": "eslint ."
},
"dependencies": {
"#react-native-firebase/app": "^6.2.0",
"#react-native-firebase/auth": "^6.2.0",
"#react-native-firebase/storage": "^6.2.0",
"#types/react": "^16.9.17",
"#types/react-native": "^0.60.31",
"jetifier": "^1.6.5",
"react": "16.9.0",
"react-native": "0.61.5",
"react-native-admob": "^2.0.0-beta.6",
"react-native-appearance": "^0.3.1",
"react-native-gesture-handler": "^1.5.3",
"react-native-image-picker": "^2.3.0",
"react-native-ionicons": "^4.6.4",
"react-native-navigation-bar-color": "^1.0.0",
"react-native-reanimated": "^1.4.0",
"react-native-restart": "0.0.14",
"react-native-splash-screen": "^3.2.0",
"react-native-typescript-transformer": "^1.2.13",
"react-native-vector-icons": "^6.6.0",
"react-navigation": "^4.0.10",
"react-navigation-stack": "^1.10.3",
"react-navigation-tabs": "^2.6.2",
"styled-components": "^5.0.1",
"typescript": "^3.7.5",
"uninstall": "0.0.0"
},
"devDependencies": {
"#babel/core": "^7.6.2",
"#babel/runtime": "^7.6.2",
"#react-native-community/eslint-config": "^0.0.5",
"babel-jest": "^24.9.0",
"eslint": "^6.5.1",
"jest": "^24.9.0",
"metro-react-native-babel-preset": "^0.56.0",
"react-test-renderer": "16.9.0"
},
"jest": {
"preset": "react-native"
}
}
Fixed by cleaning node cache and yarn cache as well as reinstalling react native firebase modules all in 6.2.0

Resources