This is the offending line of code:
<p>
{(isSameDay(event.start, event.end)) ? `On ${format(event.start, 'LLL do')}`: `From ${format(event.start, 'LLL do')} to ${format(event.end, 'LLL do')}`}
</p>
I also tried:
<p>
{(isSameDay(new Date(event.start), new Date(event.end))) ? `On ${format(new Date(event.start), 'LLL do')}`: `From ${format(new Date(event.start), 'LLL do')} to ${format(new Date(event.end), 'LLL do')}`}
</p>
and:
<p>
{(event.start === event.end) ? `On ${format(new Date(event.start), 'LLL do')}`: `From ${format(new Date(event.start), 'LLL do')} to ${format(new Date(event.end), 'LLL do')}`}
</p>
The last one comes back false when it should be true, so it doesn't even matter that it fails the build.
I also uninstalled and re-installed date-fns.
I'm able to use isBefore, isAfter, isToday on a different page, so I have no idea why this line in particular is messing me up. Is my logic wrong? What am I missing? I love date-fns and would prefer not to use a different library, and I definitely don't want to deal with dates with vanilla JavaScript, but if I can't figure this out that's probably what I'll end up doing.
Here is the output when I try to build:
info - Using webpack 5. Reason: Enabled by default https://nextjs.org/docs/messages/webpack5
info - Skipping validation of types
info - Creating an optimized production build
info - Compiled successfully
info - Collecting page data
[== ] info - Generating static pages (20/175)undefined start
undefined end
Error occurred prerendering page "/vendor/events/EventsCard". Read more: https://nextjs.org/docs/messages/prerender-error
TypeError: Cannot read property 'start' of undefined
at EventsCard (D:\boho\front\app\.next\server\chunks\9136.js:57:28)
at d (D:\boho\front\app\node_modules\react-dom\cjs\react-dom-server.node.production.min.js:33:498)
at bb (D:\boho\front\app\node_modules\react-dom\cjs\react-dom-server.node.production.min.js:36:16)
at a.b.render (D:\boho\front\app\node_modules\react-dom\cjs\react-dom-server.node.production.min.js:42:43)
at a.b.read (D:\boho\front\app\node_modules\react-dom\cjs\react-dom-server.node.production.min.js:41:83)
at Object.exports.renderToString (D:\boho\front\app\node_modules\react-dom\cjs\react-dom-server.node.production.min.js:52:138)
at renderPage (D:\boho\front\app\node_modules\next\dist\server\render.js:596:45)
at Object.ctx.renderPage (D:\boho\front\app\.next\server\pages\_document.js:53:30)
at Function.getInitialProps (D:\boho\front\app\.next\server\chunks\6859.js:603:19)
at Function.getInitialProps (D:\boho\front\app\.next\server\pages\_document.js:60:56)
info - Generating static pages (175/175)
> Build error occurred
Error: Export encountered errors on following paths:
/vendor/events/EventsCard
at D:\boho\front\app\node_modules\next\dist\export\index.js:487:19
at runMicrotasks (<anonymous>)
at processTicksAndRejections (internal/process/task_queues.js:95:5)
at async Span.traceAsyncFn (D:\boho\front\app\node_modules\next\dist\telemetry\trace\trace.js:60:20)
at async D:\boho\front\app\node_modules\next\dist\build\index.js:833:17
at async Span.traceAsyncFn (D:\boho\front\app\node_modules\next\dist\telemetry\trace\trace.js:60:20)
at async D:\boho\front\app\node_modules\next\dist\build\index.js:707:13
at async Span.traceAsyncFn (D:\boho\front\app\node_modules\next\dist\telemetry\trace\trace.js:60:20)
at async Object.build [as default] (D:\boho\front\app\node_modules\next\dist\build\index.js:77:25)
Related
I am testing s remix.run app to see how it works.
I created a posts page inside routes directory
const Posts = () => {
return (
<main>
testing
</main>
);
};
I get this error on console:
TypeError: (0 , import_jsx_dev_runtime.jsxDEV) is not a function 2ms
at /home/Documents/remix/my-remix-app/app/entry.server.jsx:82:7
at new Promise (<anonymous>)
at handleBrowserRequest (/home/Documents/remix/my-remix-app/app/entry.server.jsx:78:10)
at handleRequest (/home/Documents/remix/my-remix-app/app/entry.server.jsx:23:7)
at handleDocumentRequestRR (/home/Documents/remix/my-remix-app/node_modules/#remix-run/server-runtime/dist/server.js:260:20)
at requestHandler (/home/Documents/remix/my-remix-app/node_modules/#remix-run/server-runtime/dist/server.js:49:18)
at /home/Documents/remix/my-remix-app/node_modules/#remix-run/express/dist/server.js:39:22
On browser I see
Unexpected Server Error
This is an active issue on the official remix repository. A few fixes suggested by users:
Adding remix build to dev script in package.json:
"dev": "remix build && run-p dev:*"
Forcefully bumping esbuild version to ^0.15.8.
Reverting #remix-run/dev to 1.6.8.
I am creating react product using gatsby. I am using react-pdf library. It is givining follwoing error at build time. How can I solve it?
I used gatsby 3.3.0 version.
and using react-pdf 5.2.0
D:\Project\public\render-page.js:137661
window.requestAnimationFrame(resolve);
ReferenceError: window is not defined
at D:\Project\public\render-page.js:40343:3
at new Promise (<anonymous>)
at Object../node_modules/pdfjs-dist/lib/web/ui_utils.js (D:\Project\public\render-page.js:4034
2:26)
at __webpack_require__ (D:\Project\public\render-page.js:48664:42)
at Object../node_modules/pdfjs-dist/lib/web/pdf_link_service.js (D:\Brisktech\Android\public\render-page
.js:39345:17)
at __webpack_require__ (D:\Project\public\render-page.js:48664:42)
at Module../node_modules/react-pdf/dist/esm/LinkService.js (D:\Project\public\render-page.js:4
4080:93)
at __webpack_require__ (D:\Project\public\render-page.js:48664:42)
at Module../node_modules/react-pdf/dist/esm/Document.js (D:\Project\public\render-page.js:4351
2:71)
at __webpack_require__ (D:\Project\public\render-page.js:48664:42)
at Module../node_modules/react-pdf/dist/esm/entry.webpack.js (D:\Brisktech\Android\public\render-page.js
:46550:67)
at __webpack_require__ (D:\Project\public\render-page.js:48664:42)
at Module../src/routes/default/index.js (D:\Project\public\render-page.js:7404:90)
at __webpack_require__ (D:\Project\public\render-page.js:48664:42)
at Object../.cache/_this_is_virtual_fs_path_/$virtual/sync-requires.js (D:\Brisktech\Android\public\rend
er-page.js:6740:116)
at __webpack_require__ (D:\Project\public\render-page.js:48664:42)
D:\Project\public\render-page.js:40343
window.requestAnimationFrame(resolve);
^
failed Building static HTML for pages - 2.931s
ERROR #95313
Building static HTML failed
See our docs page for more info on this error: https://gatsby.dev/debug-html
10 |
11 | export default function _createClass(Constructor, protoProps, staticProps) {
> 12 | if (protoProps) _defineProperties(Constructor.prototype, protoProps);
| ^
13 | if (staticProps) _defineProperties(Constructor, staticProps);
14 | return Constructor;
15 | }
WebpackError: Call retries were exceeded
- createClass.js:12
[fitupme-app]/[#babel]/runtime/helpers/esm/createClass.js:12:1
error Command failed with exit code 1.
If I lower the version of react-pdf then It is working but giving warning.
react-pdf: 4.2.0
ERROR
(node:6076) [DEP_WEBPACK_COMPILATION_CACHE] DeprecationWarning: Compilation.cache was removed in favor of
Compilation.getCache()
(Use `node --trace-deprecation ...` to show where the warning was created)
ERROR
(node:6076) [DEP_WEBPACK_TEMPLATE_PATH_PLUGIN_REPLACE_PATH_VARIABLES_HASH] DeprecationWarning: [hash] is now
[fullhash] (also consider using [chunkhash] or [contenthash], see documentation for details)
ERROR
(node:6076) [DEP_WEBPACK_DEPRECATION_ARRAY_TO_SET_INDEXER] DeprecationWarning: chunk.files was changed from Array to Set (in
dexing Array is deprecated)
Can Anyone solve this?
As the error prompts in:
See our docs page for more info on this error:
https://gatsby.dev/debug-html
Your issue relies on the fact that gatsby develop occurs in the browser (where there are window and other global objects while gatsby build occurs in the Node server, where for obvious reasons there is no window (summarizing a lot).
When dealing with own code, you can bypass this issue wrapping your logic in the following condition:
import * as React from "react"
// Check if window is defined (so if in the browser or in node.js).
const isBrowser = typeof window !== "undefined"
export default function MyComponent() {
let loggedIn = false
if (isBrowser) {
window.localstorage.getItem("isLoggedIn") === "true"
}
return <div>Am I logged in? {loggedIn}</div>
}
Source: https://www.gatsbyjs.com/docs/debugging-html-builds/
The snippet above will avoid a breaking build because it won't execute the offending part of the code thanks to typeof window !== "undefined" condition.
However, in your case, you are not dealing with own code so you need to tell webpack to avoid the transpilation of the offending modules. Add the following snippet in your gatsby-node.js:
exports.onCreateWebpackConfig = ({ stage, loaders, actions }) => {
if (stage === "build-html" || stage === "develop-html") {
actions.setWebpackConfig({
module: {
rules: [
{
test: /bad-module/,
use: loaders.null(),
},
],
},
})
}
}
Basically, you are overwriting webpack's default configuration by telling it to ignore (or to add a null loader) to the /bad-module/ dependency. As you can see, the test rule is a regular expression (that's why is wrapped between slashes) so you will need to change /bad-module/ for the name of the dependency in node_modules. Something like this should work:
exports.onCreateWebpackConfig = ({ stage, loaders, actions }) => {
if (stage === "build-html" || stage === "develop-html") {
actions.setWebpackConfig({
module: {
rules: [
{
test: /react-pdf/, // check /pdfjs-dist/ too
use: loaders.null(),
},
],
},
})
}
}
react-pdf is trying to use window and/or document, what are undefined global objects at build-time to make their stuff so you are forced to pass a null loader to avoid the code-breaking. This is a "common" practice when dealing with third-party dependencies that use window in Gatsby.
Since it may not be exactly the third-party dependency that is causing the issue (it may be some dependency of react-pdf) you will need to make some trials testing dependencies based on the output log. Clean the cache in each trial using gatsby clean command.
My Next JS website was working perfectly, one day when I tried to install Apollo Rest from here https://www.apollographql.com/docs/link/links/rest/#gatsby-focus-wrapper I began having a lot of errors.
I discard any changes in packages.json, removed packages-lock.json, node_modules and dust file and folders. But keep getting the next error:
GraphQL error occurred [getDataFromTree] TypeError: Cannot read property 'indexOf' of undefined
at addBasePath (F:\Projects\breadcrumps\showcase\dist\functions\next\server\static\development\pages\index.js:2966:15)
at F:\Projects\breadcrumps\showcase\dist\functions\next\server\static\development\pages\index.js:2464:40
at Link.formatUrls (F:\Projects\breadcrumps\showcase\dist\functions\next\server\static\development\pages\index.js:2388:18)
at Link.render (F:\Projects\breadcrumps\showcase\dist\functions\next\server\static\development\pages\index.js:2588:14)
at processChild (F:\Projects\breadcrumps\showcase\node_modules\react-dom\cjs\react-dom-server.node.development.js:3134:18)
at resolve (F:\Projects\breadcrumps\showcase\node_modules\react-dom\cjs\react-dom-server.node.development.js:2960:5)
at ReactDOMServerRenderer.render (F:\Projects\breadcrumps\showcase\node_modules\react-dom\cjs\react-dom-server.node.development.js:3435:22)
at ReactDOMServerRenderer.read (F:\Projects\breadcrumps\showcase\node_modules\react-dom\cjs\react-dom-server.node.development.js:3373:29)
at renderToStaticMarkup (F:\Projects\breadcrumps\showcase\node_modules\react-dom\cjs\react-dom-server.node.development.js:4004:27)
at process (F:\Projects\breadcrumps\showcase\node_modules\#apollo\react-ssr\lib\react-ssr.cjs.js:38:16)
at runMicrotasks (<anonymous>)
at processTicksAndRejections (internal/process/task_queues.js:97:5)
TypeError: Cannot read property 'indexOf' of undefined
at addBasePath (F:\Projects\breadcrumps\showcase\dist\functions\next\server\static\development\pages\index.js:2966:15)
at F:\Projects\breadcrumps\showcase\dist\functions\next\server\static\development\pages\index.js:2464:40
at Link.formatUrls (F:\Projects\breadcrumps\showcase\dist\functions\next\server\static\development\pages\index.js:2388:18)
at Link.render (F:\Projects\breadcrumps\showcase\dist\functions\next\server\static\development\pages\index.js:2588:14)
at processChild (F:\Projects\breadcrumps\showcase\node_modules\react-dom\cjs\react-dom-server.node.development.js:3134:18)
at resolve (F:\Projects\breadcrumps\showcase\node_modules\react-dom\cjs\react-dom-server.node.development.js:2960:5)
at ReactDOMServerRenderer.render (F:\Projects\breadcrumps\showcase\node_modules\react-dom\cjs\react-dom-server.node.development.js:3435:22)
at ReactDOMServerRenderer.read (F:\Projects\breadcrumps\showcase\node_modules\react-dom\cjs\react-dom-server.node.development.js:3373:29)
at renderToString (F:\Projects\breadcrumps\showcase\node_modules\react-dom\cjs\react-dom-server.node.development.js:3988:27)
at render (F:\Projects\breadcrumps\showcase\node_modules\next\dist\next-server\server\render.js:83:16)
at renderPage (F:\Projects\breadcrumps\showcase\node_modules\next\dist\next-server\server\render.js:415:16)
at Object.ctx.renderPage (F:\Projects\breadcrumps\showcase\dist\functions\next\server\static\development\pages\_document.js:905:30)
at Function.getInitialProps (F:\Projects\breadcrumps\showcase\dist\functions\next\server\static\development\pages\_document.js:247:19)
at Function.getInitialProps (F:\Projects\breadcrumps\showcase\dist\functions\next\server\static\development\pages\_document.js:916:85)
at Object.loadGetInitialProps (F:\Projects\breadcrumps\showcase\node_modules\next\dist\next-server\lib\utils.js:59:29)
at Object.renderToHTML (F:\Projects\breadcrumps\showcase\node_modules\next\dist\next-server\server\render.js:419:36)
Error: "CustomDocument.getInitialProps()" should resolve to an object. But found "undefined" instead.
at Object.loadGetInitialProps (F:\Projects\breadcrumps\showcase\node_modules\next\dist\next-server\lib\utils.js:65:15)
at runMicrotasks (<anonymous>)
at processTicksAndRejections (internal/process/task_queues.js:97:5)
at async Object.renderToHTML (F:\Projects\breadcrumps\showcase\node_modules\next\dist\next-server\server\render.js:419:22)
at async DevServer.renderToHTMLWithComponents (F:\Projects\breadcrumps\showcase\node_modules\next\dist\next-server\server\next-server.js:654:26)
at async DevServer.renderToHTML (F:\Projects\breadcrumps\showcase\node_modules\next\dist\next-server\server\next-server.js:801:28)
at async DevServer.renderToHTML (F:\Projects\breadcrumps\showcase\node_modules\next\dist\server\next-dev-server.js:22:539)
at async DevServer.render (F:\Projects\breadcrumps\showcase\node_modules\next\dist\next-server\server\next-server.js:546:22)
at async Object.fn (F:\Projects\breadcrumps\showcase\node_modules\next\dist\next-server\server\next-server.js:396:17)
at async Router.execute (F:\Projects\breadcrumps\showcase\node_modules\next\dist\next-server\server\router.js:134:32)
at async DevServer.run (F:\Projects\breadcrumps\showcase\node_modules\next\dist\next-server\server\next-server.js:511:29)
at async DevServer.handleRequest (F:\Projects\breadcrumps\showcase\node_modules\next\dist\next-server\server\next-server.js:147:20)
Any hints to solve this annoying problem I will be grateful.
I found where is the problem, one of my websites link getting undefined value.
I am using 'next/link' component.
But it's not logical to get all these three exceptions for an undefined URL passed to that linked. I think NextJS development team should review more how they are logging an exception. And even if I passed undefined for that component, there should be a check for that, not the whole website should go down.
This may not apply to your install of Apollo, but I got the same error because I was using the react-router-dom syntax for Link:
<Link to="/home">
Changing it to the NextJs syntax fixed it for me:
<Link href="/home">
NextJs docs here:
https://nextjs.org/learn/basics/navigate-between-pages/link-component
For anyone else searching this error, I got a when passing Link as a prop to Material-UI ListItem that had been previously used to pass a react-router-dom Link in the component prop as so:
<ListItem
key={page.title}
activeClassName={classes.activeListItem}
className={classes.listItem}
to={page.href}
component={Link}
>
and can be changed to:
<Link href={page.href}>
<ListItem
key={page.title}
activeClassName={classes.activeListItem}
className={classes.listItem}
>
</Link>
I am trying to make a React app with Azure SignalR, using this tutorial as a base. I haven't changed anything about the SignalR server, which can be found here. I'm using the JS version. The app works fine otherwise, but whenever the state changes, requests are sent to SignalR or something along those lines, eventually causing a 429 error. This is the output when state changes once:
[2020-01-09T15:11:42.207Z] Information: Normalizing '/api' to 'http://localhost:3000/api'.
[2020-01-09T15:11:42.437Z] Information: WebSocket connected to wss://bpm-drawing.service.signalr.net/client/?hub=chat&id=5_gylFnC52hduxXnoFT7dgb3b5d12b1&access_token=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJuYmYiOjE1Nzg1ODI3MDIsImV4cCI6MTU3ODU4NDUwMiwiaWF0IjoxNTc4NTgyNzAyLCJhdWQiOiJodHRwczovL2JwbS1kcmF3aW5nLnNlcnZpY2Uuc2lnbmFsci5uZXQvY2xpZW50Lz9odWI9Y2hhdCJ9.byfLiITpaUPm9OLxjn-EN8XcwDT3_j6tdoN2uSdR91k.
[2020-01-09T15:11:42.440Z] Information: Using HubProtocol 'json'.
Enough consequent state changes cause a 429 error. Some of the error messages:
WebSocket connection to 'wss://bpm-drawing.service.signalr.net/client/?hub=chat&id=zer-1PBd58usOkZ2n-3Wuwb3b5d12b1&access_token=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJuYmYiOjE1Nzg1ODI4OTYsImV4cCI6MTU3ODU4NDY5NiwiaWF0IjoxNTc4NTgyODk2LCJhdWQiOiJodHRwczovL2JwbS1kcmF3aW5nLnNlcnZpY2Uuc2lnbmFsci5uZXQvY2xpZW50Lz9odWI9Y2hhdCJ9.t7HPErziiAbQX1PLONvtF3tSHa4ezcBNgAhb0tgNJYA' failed: Error during WebSocket handshake: Unexpected response code: 429
[2020-01-09T15:14:59.060Z] Error: Failed to start the transport 'WebSockets': Error: There was an error with the transport.
POST https://bpm-drawing.service.signalr.net/client/negotiate?hub=chat&negotiateVersion=1 429
[2020-01-09T15:14:59.143Z] Error: Failed to complete negotiation with the server: Error
[2020-01-09T15:14:59.148Z] Error: Failed to start the connection: Error
Errors.ts:20 Uncaught (in promise) Error
at new HttpError (Errors.ts:20)
at XMLHttpRequest.xhr.onload (XhrHttpClient.ts:70)
I stripped my code down quite a bit but this is enough to cause the error:
import React from "react";
const signalR = require("#microsoft/signalr");
export const App = () => {
const [message, setMessage] = React.useState("");
const connection = new signalR.HubConnectionBuilder()
.withUrl(`/api`)
.configureLogging(signalR.LogLevel.Information)
.build();
connection.onclose(() => console.log("disconnected"));
connection.start();
function updateMsg(e) {
e.preventDefault();
setMessage(e.target.value);
}
return (
<div>
<form>
<input
type="text"
placeholder="Type message here..."
onChange={updateMsg}
/>
</form>
</div>
);
};
export default App;
The npm server just has a lot of
[HPM] POST /api/negotiate?negotiateVersion=1 -> http://localhost:7071
Okay so the problem is that the code inside App is run every time state updates, so the connection is formed again. Still haven't figured out quite how to solve it but at least I know what the cause is.
EDIT: Since I was asked, the solution is to put the forming of the connection inside a 'useEffect' hook, so that it's only run once, when the component is mounted.
I had following html code,
index.html
<li class = "list-group-item" style="margin:50px;" ng-repeat="product in store.products">
<h3>
{{product.name}}
<em class="pull-right">{{product.price | currency}} </em>
</h3>
</li>
In order to get to know the directive ng-include,I added another html in the same directory of index.html.
product-title.html
{{product.name}}
<em class="pull-right">{{product.price | currency}} </em>
And I changed the index.html to,
<h3 ng-include="'product-title.html'">
</h3>
But when I run the index,html, I am not getting the h3 details,
Please help me to find the mistake.
My Controller:
var app = angular.module("store", []);
app.controller('StoreController', function () {
this.products = gems;
});
var gems = [
{
name: 'Product1',
price: '2',
description: 'Bla bla bla',
images: [...],
reviews: [...]
},
{ .....}
];
Browser Error:
Error: Failed to execute 'send' on 'XMLHttpRequest': Failed to load 'file:///D:/Angular%20JS/Source%20Codes/product-title.html'.
at Error (native)
at file:///D:/Angular%20JS/Source%20Codes/angular.min.js:79:137
at s (file:///D:/Angular%20JS/Source%20Codes/angular.min.js:74:109)
at f (file:///D:/Angular%20JS/Source%20Codes/angular.min.js:71:429)
at L (file:///D:/Angular%20JS/Source%20Codes/angular.min.js:100:187)
at L (file:///D:/Angular%20JS/Source%20Codes/angular.min.js:100:187)
at file:///D:/Angular%20JS/Source%20Codes/angular.min.js:101:350
at k.$eval (file:///D:/Angular%20JS/Source%20Codes/angular.min.js:112:68)
at k.$digest (file:///D:/Angular%20JS/Source%20Codes/angular.min.js:109:147)
at k.$apply (file:///D:/Angular%20JS/Source%20Codes/angular.min.js:112:398) angular.min.js:92
(anonymous function) angular.min.js:92
(anonymous function) angular.min.js:68
L angular.min.js:100
L angular.min.js:100
(anonymous function) angular.min.js:101
k.$eval angular.min.js:112
k.$digest angular.min.js:109
k.$apply angular.min.js:112
(anonymous function) angular.min.js:18
d angular.min.js:35
c angular.min.js:18
fc angular.min.js:18
Xc angular.min.js:17
(anonymous function) angular.min.js:214
a angular.min.js:145
(anonymous function) angular.min.js:31
r angular.min.js:7
c
You should not be loading index.html from file:///.... Most browsers will have issues loading data from file URLs, because it triggers cross site scripting protection. Instead, host your directory on a local webserver like LAMP or nodeJs, so your files are coming from http://localhost/....
Another way to solve the issue is to create the website using Microsoft Visual Studio Express for Web. (This version is for free).
Once you run your website you will get http://localhost/....
I had same issue while running through "file://....".
If you are using Mac or Linux, run your app with python simplehttpserver without installing anything.
1. cd [your-project-dir]
2. python -m SimpleHTTPServer
Your app will run on http://localhost:8000/