CssSyntaxError - unknown word in Tailwind and Next.js project - reactjs

10 hours later and still cannot deploy my application due to below build failure. Using React/Next with Tailwind.
I believe it comes from PostCSS plugin but I cant find any of my errors (if it is one), it runs perfectly on localhost before production build. Any way to identify which class that is the error?
I get the following error when I deploy.
HookWebpackError: /vercel/path0/static/css/50ca08b8d4bb65eb.css:1043:73: Unknown word
at makeWebpackError (/vercel/path0/node_modules/next/dist/compiled/webpack/bundle5.js:41664:9)
at /vercel/path0/node_modules/next/dist/compiled/webpack/bundle5.js:25354:12
at eval (eval at create (/vercel/path0/node_modules/next/dist/compiled/webpack/bundle5.js:140346:10), <anonymous>:34:1)
at runMicrotasks (<anonymous>)
at processTicksAndRejections (internal/process/task_queues.js:95:5)
-- inner error --
CssSyntaxError: /vercel/path0/static/css/50ca08b8d4bb65eb.css:1043:73: Unknown word
at Input.error (/vercel/path0/node_modules/next/node_modules/postcss/lib/input.js:148:16)
at ScssParser.unknownWord (/vercel/path0/node_modules/next/node_modules/postcss/lib/parser.js:522:22)
at ScssParser.other (/vercel/path0/node_modules/next/node_modules/postcss/lib/parser.js:149:12)
at ScssParser.parse (/vercel/path0/node_modules/next/node_modules/postcss/lib/parser.js:59:16)
at scssParse (/vercel/path0/node_modules/next/dist/compiled/postcss-scss/scss-syntax.js:1:322)
at new LazyResult (/vercel/path0/node_modules/next/node_modules/postcss/lib/lazy-result.js:133:16)
at Processor.process (/vercel/path0/node_modules/next/node_modules/postcss/lib/processor.js:28:14)
at CssMinimizerPlugin.optimizeAsset (/vercel/path0/node_modules/next/dist/build/webpack/plugins/css-minimizer-plugin.js:43:12)
at /vercel/path0/node_modules/next/dist/build/webpack/plugins/css-minimizer-plugin.js:77:55
at runMicrotasks (<anonymous>)
caused by plugins in Compilation.hooks.processAssets
CssSyntaxError: /vercel/path0/static/css/50ca08b8d4bb65eb.css:1043:73: Unknown word
at Input.error (/vercel/path0/node_modules/next/node_modules/postcss/lib/input.js:148:16)
at ScssParser.unknownWord (/vercel/path0/node_modules/next/node_modules/postcss/lib/parser.js:522:22)
at ScssParser.other (/vercel/path0/node_modules/next/node_modules/postcss/lib/parser.js:149:12)
at ScssParser.parse (/vercel/path0/node_modules/next/node_modules/postcss/lib/parser.js:59:16)
at scssParse (/vercel/path0/node_modules/next/dist/compiled/postcss-scss/scss-syntax.js:1:322)
at new LazyResult (/vercel/path0/node_modules/next/node_modules/postcss/lib/lazy-result.js:133:16)
at Processor.process (/vercel/path0/node_modules/next/node_modules/postcss/lib/processor.js:28:14)
at CssMinimizerPlugin.optimizeAsset (/vercel/path0/node_modules/next/dist/build/webpack/plugins/css-minimizer-plugin.js:43:12)
at /vercel/path0/node_modules/next/dist/build/webpack/plugins/css-minimizer-plugin.js:77:55
at runMicrotasks (<anonymous>)
> Build failed because of webpack errors
Error: Command "npm run build" exited with 1
I've seen other threads such as Unknown word error from CSS Minimizer plugin on React build, and tried following guidelines but I cannot find any Tailwind class which may be incorrect or to advanced, at least not manually. Any ways to do this with help from extension or similar?

Check out this thread: Why am I getting this error (Tailwind + Next.js)? HookwebpackError, CssSyntaxError
In my case, the issue was with my tailwind.config.js.
First, I'd look for any dynamic classnames, searching for [${ or similar in your codebase to find them.
After removing those and still failing, I restored a previous version of tailwind.config.js from git that I knew was previously working, and it was able to build succcessfully.
Specifically, the build was failing due to including:
extend: {
backgroundImage: {
"primary-underline": "linear-gradient(180deg,transparent 80%,hsla(205,100%,55%,0.5) 0);"
},
}
The ; at EOL was the culprit.

Related

React Native Expo errors like "None of these files exist" start happing in new

I followed the inst here: https://docs.expo.dev/guides/typescript/ and ran npx create-expo-app -t expo-template-blank-typescript
I do some basic things and then try revert back to a working state and fail
And this is the 2nd time I get errors like this which nobody can give me a soln for:
None of these files exist:
* node_modules/expo/AppEntry(.native|.ios.ts|.native.ts|.ts|.ios.tsx|.native.tsx|.tsx|.ios.js|.native.js|.js|.ios.jsx|.native.jsx|.jsx|.ios.json|.native.json|.json)
* node_modules/expo/AppEntry/index(.native|.ios.ts|.native.ts|.ts|.ios.tsx|.native.tsx|.tsx|.ios.js|.native.js|.js|.ios.jsx|.native.jsx|.jsx|.ios.json|.native.json|.json)
at ModuleResolver.resolveDependency (/Users/nikos/WebstormProjects/photo-verify/node_modules/.pnpm/metro#0.70.3/node_modules/metro/src/node-haste/DependencyGraph/ModuleResolution.js:136:15)
at DependencyGraph.resolveDependency (/Users/nikos/WebstormProjects/photo-verify/node_modules/.pnpm/metro#0.70.3/node_modules/metro/src/node-haste/DependencyGraph.js:231:43)
at /Users/nikos/WebstormProjects/photo-verify/node_modules/.pnpm/metro#0.70.3/node_modules/metro/src/lib/transformHelpers.js:129:24
at Server._resolveRelativePath (/Users/nikos/WebstormProjects/photo-verify/node_modules/.pnpm/metro#0.70.3/node_modules/metro/src/Server.js:1137:12)
at async Server.requestProcessor [as _processBundleRequest] (/Users/nikos/WebstormProjects/photo-verify/node_modules/.pnpm/metro#0.70.3/node_modules/metro/src/Server.js:464:37)
at async Server._processRequest (/Users/nikos/WebstormProjects/photo-verify/node_modules/.pnpm/metro#0.70.3/node_modules/metro/src/Server.js:420:9)
info Launching Dev Tools...
Error: Unable to resolve module ./node_modules/expo/AppEntry from /Users/nikos/WebstormProjects/photo-verify/.:
None of these files exist:
* node_modules/expo/AppEntry(.native|.ios.ts|.native.ts|.ts|.ios.tsx|.native.tsx|.tsx|.ios.js|.native.js|.js|.ios.jsx|.native.jsx|.jsx|.ios.json|.native.json|.json)
* node_modules/expo/AppEntry/index(.native|.ios.ts|.native.ts|.ts|.ios.tsx|.native.tsx|.tsx|.ios.js|.native.js|.js|.ios.jsx|.native.jsx|.jsx|.ios.json|.native.json|.json)
at ModuleResolver.resolveDependency (/Users/nikos/WebstormProjects/photo-verify/node_modules/.pnpm/metro#0.70.3/node_modules/metro/src/node-haste/DependencyGraph/ModuleResolution.js:136:15)
at DependencyGraph.resolveDependency (/Users/nikos/WebstormProjects/photo-verify/node_modules/.pnpm/metro#0.70.3/node_modules/metro/src/node-haste/DependencyGraph.js:231:43)
at /Users/nikos/WebstormProjects/photo-verify/node_modules/.pnpm/metro#0.70.3/node_modules/metro/src/lib/transformHelpers.js:129:24
at Server._resolveRelativePath (/Users/nikos/WebstormProjects/photo-verify/node_modules/.pnpm/metro#0.70.3/node_modules/metro/src/Server.js:1137:12)
at async Server.requestProcessor [as _processBundleRequest] (/Users/nikos/WebstormProjects/photo-verify/node_modules/.pnpm/metro#0.70.3/node_modules/metro/src/Server.js:464:37)
at async Server._processRequest (/Users/nikos/WebstormProjects/photo-verify/node_modules/.pnpm/metro#0.70.3/node_modules/metro/src/Server.js:420:9)
May be you've added /node_modules/ to your "ignore_dirs" of your .watchmanconfig file. You need to remove it.
Then, clear your watchman cache with the following command : watchman watch-del-all.
Clear also your metro cache to be sure to rebuild your app. Just add --clear option to your expo start command, in other words, run npx expo start --clear.

How do I find where 'given node is not an Element, the node type is: string' error occurred from stack trace? (react/JS)

I'm writing a react app as a practice and I get the following error on several components, however I can't see that it tells me where it comes from? It doesn't prevent tests (jest/react testing library) passing or indeed build (WIP app is successfully deployed to netlify). Nevertheless, I'd like to track it down if only for understanding:
Error: The given node is not an Element, the node type is: string.
at getWindowFromNode (/Users/learning/Documents/projects/mol-bio-tools/node_modules/#testing-library/dom/dist/helpers.js:58:11)
at hasPointerEvents (/Users/learning/Documents/projects/mol-bio-tools/node_modules/#testing-library/user-event/dist/utils/misc/hasPointerEvents.js:11:49)
at click (/Users/learning/Documents/projects/mol-bio-tools/node_modules/#testing-library/user-event/dist/click.js:116:63)
at typeImplementation (/Users/learning/Documents/projects/mol-bio-tools/node_modules/#testing-library/user-event/dist/type/typeImplementation.js:24:36)
at Object.type (/Users/learning/Documents/projects/mol-bio-tools/node_modules/#testing-library/user-event/dist/type/index.js:27:60)
at Object.<anonymous> (/Users/learning/Documents/projects/mol-bio-tools/src/__tests__/transcribe.test.js:33:15)
at Promise.then.completed (/Users/learning/Documents/projects/mol-bio-tools/node_modules/jest-circus/build/utils.js:391:28)
at new Promise (<anonymous>)
at callAsyncCircusFn (/Users/learning/Documents/projects/mol-bio-tools/node_modules/jest-circus/build/utils.js:316:10)
at _callCircusTest (/Users/learning/Documents/projects/mol-bio-tools/node_modules/jest-circus/build/run.js:218:40)
at processTicksAndRejections (node:internal/process/task_queues:95:5)
at _runTest (/Users/learning/Documents/projects/mol-bio-tools/node_modules/jest-circus/build/run.js:155:3)
at _runTestsForDescribeBlock (/Users/learning/Documents/projects/mol-bio-tools/node_modules/jest-circus/build/run.js:66:9)
at _runTestsForDescribeBlock (/Users/learning/Documents/projects/mol-bio-tools/node_modules/jest-circus/build/run.js:60:9)
at run (/Users/learning/Documents/projects/mol-bio-tools/node_modules/jest-circus/build/run.js:25:3)
at runAndTransformResultsToJestFormat (/Users/learning/Documents/projects/mol-bio-tools/node_modules/jest-circus/build/legacy-code-todo-rewrite/jestAdapterInit.js:170:21)
at jestAdapter (/Users/learning/Documents/projects/mol-bio-tools/node_modules/jest-circus/build/legacy-code-todo-rewrite/jestAdapter.js:82:19)
at runTestInternal (/Users/learning/Documents/projects/mol-bio-tools/node_modules/jest-runner/build/runTest.js:389:16)
at runTest (/Users/learning/Documents/projects/mol-bio-tools/node_modules/jest-runner/build/runTest.js:475:34)
at Object.worker (/Users/learning/Documents/projects/mol-bio-tools/node_modules/jest-runner/build/testWorker.js:133:12)
Current complete code is here and live app is here (again: WIP - I know various links/etc don't work yet).
Turns out if I actually read that trace it highlights an error in my test:
at Object.<anonymous> (/Users/learning/Documents/projects/mol-bio-tools/src/__tests__/transcribe.test.js:33:15)
Turns out I'd managed to use a hybrid of #testing-library/userevent v13.5 and v14 syntax, and there are breaking changes between the 2 versions. Updated to v14, updated syntax, all good.

Importing markdown in react caused "marked is not a function" or The "data" argument ... error

I know there are lots of "marked is not a function" questions, but they don't solve my problem, hence here is the question.
Previously I think I npm i marked and npm i react-markdown, then I try to include markdown using the solution How do I load a markdown file into a react component?
However, I keep getting either of these error:
🚨 The "data" argument must be of type string or an instance of Buffer, TypedArray, or DataView. Received null
at new NodeError (internal/errors.js:322:7)
at Hash.update (internal/crypto/hash.js:84:11)
at Bundle.getHash (/home/azureuser/NCD_demo/main_project/node_modules/parcel-bundler/src/Bundle.js:301:12)
at Bundle.package (/home/azureuser/NCD_demo/main_project/node_modules/parcel-bundler/src/Bundle.js:186:23)
at Bundle.package (/home/azureuser/NCD_demo/main_project/node_modules/parcel-bundler/src/Bundle.js:198:30)
at Bundle.package (/home/azureuser/NCD_demo/main_project/node_modules/parcel-bundler/src/Bundle.js:198:30)
at Bundler.bundle (/home/azureuser/NCD_demo/main_project/node_modules/parcel-bundler/src/Bundler.js:325:49)
at processTicksAndRejections (internal/process/task_queues.js:95:5)
at async Timeout._onTimeout (/home/azureuser/NCD_demo/main_project/node_modules/parcel-bundler/src/Bundler.js:817:7)
Or
🚨 /home/azureuser/NCD_demo/main_project/src/webpages/assets/posts.md: marked is not a function
at MarkdownAsset.generate (/home/azureuser/NCD_demo/main_project/node_modules/parcel-bundler/src/assets/MarkdownAsset.js:12:12)
at async MarkdownAsset.process (/home/azureuser/NCD_demo/main_project/node_modules/parcel-bundler/src/Asset.js:217:24)
at async Pipeline.processAsset (/home/azureuser/NCD_demo/main_project/node_modules/parcel-bundler/src/Pipeline.js:46:7)
at async Pipeline.process (/home/azureuser/NCD_demo/main_project/node_modules/parcel-bundler/src/Pipeline.js:24:23)
at async Object.run (/home/azureuser/NCD_demo/main_project/node_modules/parcel-bundler/src/worker.js:15:12)
at async Bundler.loadAsset (/home/azureuser/NCD_demo/main_project/node_modules/parcel-bundler/src/Bundler.js:577:19)
at async /home/azureuser/NCD_demo/main_project/node_modules/parcel-bundler/src/Bundler.js:610:13
at async Promise.all (index 4)
at async Bundler.loadAsset (/home/azureuser/NCD_demo/main_project/node_modules/parcel-bundler/src/Bundler.js:599:21)
at async /home/azureuser/NCD_demo/main_project/node_modules/parcel-bundler/src/Bundler.js:610:13
I got the first error if I run npm run dev then I uncomment this line, after which it reloads itself
const content = require('./assets/posts.md');
Then I got the latter error if I don't comment it, CTRL+C the previous npm dev run, then npm dev run again with it uncommented.
I got the same error if I do this instead:
import file from "./assets/posts.md";
I even try to
Without the line, everything runs fine.
I even tried remove package-lock.json and node_modules, remove the dependencies for React-markdown and marked packages (so they don't get installed), but I still got the similar problem: Except that I don't get the first error but white screen of death.
Anyone encountered the same problem before could help me understand what is happening with this? Which error code is correct and how should I fix it?
Thanks in advance.

next.js npm module comment giving an error

This is my error
10:03:56.049 ./components/navbar.js
10:03:56.049 13:33 Warning: img elements must have an alt prop, either with meaningful text, or an empty string for decorative images. jsx-a11y/alt-text
10:03:56.049 39:33 Warning: img elements must have an alt prop, either with meaningful text, or an empty string for decorative images. jsx-a11y/alt-text
10:03:56.049 Need to disable some ESLint rules? Learn more here: https://nextjs.org/docs/basic-features/eslint#disabling-rules
10:03:56.051 info - Creating an optimized production build...
10:04:04.307 Failed to compile.
10:04:04.308 HookWebpackError: Unexpected '/'. Escaping special characters with \ may help.
10:04:04.308 > Build error occurred
10:04:04.309 Error: > Build failed because of webpack errors
10:04:04.309 at /vercel/path0/node_modules/next/dist/build/index.js:15:924
10:04:04.309 at async Span.traceAsyncFn (/vercel/path0/node_modules/next/dist/telemetry/trace/trace.js:6:584)
10:04:04.333 Error: Command "npm run build" exited with 1
At first I thought it was coming from navbar.js but I don't see any "special characters" there, here is my navbar.js: https://pastebin.com/8XFUtL5A
So then I went and checked node_modules/next/dist/telemetry/trace/trace.js:6:584 and I found a lot of comments there: https://pastecord.com/epygazosib.js
So how do I solve this error? Because I saw a similar error someone else had but they are using angular
I have fixed this by simply removing all the comments in all my css files
In my case I made a mistake in the comments in my stylesheet page.
I had something like this
/*/*Comment*/
*/.className{
}
so removing the comment solved the bug for me.
/*Comment*/
.className{
}

howtographql + React tutorial : Error: Cannot find module './generated/prisma.graphql'

I'm following the howtographql + React tutorial right now. I'm currently at the beginning of the tutorial when I have to define my queries, mutation and stuff in my schema.graphql. But according to the tutorial, I have to import prisma.graphql from the generatedfolder by writing the following line :
# import Link, Vote, LinkSubscriptionPayload, VoteSubscriptionPayload from "./generated/prisma.graphql"
I indeed generated the serverfolder which contains everything except this file that is supposed to be generated as well I guess.
Apparently, I should be able to run the server using yarn startbut when I'm doing so, I have this message :
Error: Cannot find module './generated/prisma.graphql'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:609:15)
at resolveFileName (/Users/hamza/tfeScreen/reactapp/react-apollo/server/node_modules/resolve-from/index.js:29:39)
at resolveFrom (/Users/hamza/tfeScreen/reactapp/react-apollo/server/node_modules/resolve-from/index.js:43:9)
at module.exports (/Users/hamza/tfeScreen/reactapp/react-apollo/server/node_modules/resolve-from/index.js:46:41)
at resolveModuleFilePath (/Users/hamza/tfeScreen/reactapp/react-apollo/server/node_modules/graphql-import/dist/index.js:150:24)
at /Users/hamza/tfeScreen/reactapp/react-apollo/server/node_modules/graphql-import/dist/index.js:187:30
at Array.forEach (<anonymous>)
at collectDefinitions (/Users/hamza/tfeScreen/reactapp/react-apollo/server/node_modules/graphql-import/dist/index.js:185:16)
at Object.importSchema (/Users/hamza/tfeScreen/reactapp/react-apollo/server/node_modules/graphql-import/dist/index.js:73:14)
at mergeTypeDefs (/Users/hamza/tfeScreen/reactapp/react-apollo/server/node_modules/graphql-yoga/dist/index.js:412:37)
I don't understand what I'm doing wrong...
Do you guys have any idea ?

Resources