Open moderngeekcloud opened 5 years ago
No idea why this would be happening now. I think you're the second person to come across this, so there's probably something going on. However, it's still working fine for me, so it's difficult to test.
Does it still build properly on the previous machine?
I had the same problem with Node v12.10, downgrading to v11.15 fixed it for me.
Ran into this issue on node v12.11.1
, downgrading fixed it for me as well. It looks like the latest version of node breaks navi.
Confirmed that v12 and v13 will cause this error. Downgrade to v11.15 works.
I'm new to Navi and after implementing static rendering just ran into this issue - I downgraded to Node 10 with NVM as a test and I'm still getting the "Couldn't find window.NaviScripts" error, except in this case it's only referencing:
crawl (../node_modules/navi-scripts/lib/crawl.js:22:15)
In Node 12+ I get the same error as @moderngeekcloud.
Looking at crawl.js, the relevant code seems to be:
async function crawl(config) {
let scriptRunner = await createScriptRunner(config)
let app = await scriptRunner()
// routes should be a property of app, it is somehow undefined
if (!app.routes) {
throw new Error(`Couldn't find window.NaviScripts - did you call register()?`)
}
return await Navi.crawl({
routes: app.routes,
context: config.context,
})
}
I ran some console.logs in crawl.js and this is what I got:
console.log(config)
{ getPagePathname: [Function: getPagePathname],
createRedirectFiles: [AsyncFunction: createRedirectFiles],
context: {},
root: 'C:\\DIR\\project\\build',
entry: 'C:\\DIR\\project\\build\\index.html',
appGlobal: 'NaviScripts',
fs:
{ readFile: [Function],
writeFile: [Function: writeFile],
ensureDir: [Function: mkdirs],
exists: [Function] },
renderPageToString:
'C:\\DIR\\project\\node_modules\\react-navi\\create-react-app.js' }
console.log(app):
{ isBuild: true }
So what I can tell at the moment is that createScriptRunner takes a config object, returns a promise and evaluates to an app object that has isBuild and routes properties, but the routes property is not being passed to the app object.
Further up the chain, during the build process the following line is logged:
navi-scripts: No config file found, using default config
I'm wondering if I've missed something in the docs about passing a config option somewhere? I've followed the examples from here:
https://frontarm.com/navi/en/guides/static-rendering/#navi-scriptsregister https://github.com/frontarm/navi/blob/master/examples/basic-static-rendering/src/index.js https://github.com/frontarm/navi/blob/master/examples/basic-static-rendering/src/App.js
Additional notes:
I installed Node 11.14.0 and still get the error only in crawl.js. Same with 11.15.0.
Moving back up to Node 12.7 I get the error in crawl.js, build.js and navi-scripts.js.
Deleting node_modules and reinstalling 11.15.0 from scratch also just leads to the same error in crawl.js:22:15
Kind of at a loss, will update if I find anything out.
Running with node v12.10.0
, and get the error:
You may serve it with a static server:
npm install -g serve
serve -s build
Find out more about deployment here:
https://bit.ly/CRA-deploy
navi-scripts: Using config at /apps/PG/project/PG/blog/navi.config.js
Error: Uncaught [Error: ]
at reportException (/apps/PG/project/PG/blog/node_modules/jsdom/lib/jsdom/living/helpers/runtime-script-errors.js:62:24)
at processJavaScript (/apps/PG/project/PG/blog/node_modules/jsdom/lib/jsdom/living/nodes/HTMLScriptElement-impl.js:243:7)
at HTMLScriptElementImpl._innerEval (/apps/PG/project/PG/blog/node_modules/jsdom/lib/jsdom/living/nodes/HTMLScriptElement-impl.js:168:5)
at onLoadExternalScript (/apps/PG/project/PG/blog/node_modules/jsdom/lib/jsdom/living/nodes/HTMLScriptElement-impl.js:90:12)
at onLoadWrapped (/apps/PG/project/PG/blog/node_modules/jsdom/lib/jsdom/browser/resources/per-document-resource-loader.js:53:33)
at Object.check (/apps/PG/project/PG/blog/node_modules/jsdom/lib/jsdom/browser/resources/resource-queue.js:76:23)
at /apps/PG/project/PG/blog/node_modules/jsdom/lib/jsdom/browser/resources/resource-queue.js:83:27 Error:
at XMLHttpRequest.send (/apps/PG/project/PG/blog/node_modules/jsdom/lib/jsdom/living/xmlhttprequest.js:616:17)
at s (/static/js/2.9369d994.chunk.js:1:1043462)
at H (/static/js/main.6cdcf9ed.chunk.js:1:3982)
at Object.156 (/static/js/main.6cdcf9ed.chunk.js:1:4104)
at p (about:blank:1:526)
at Module.775 (/static/js/main.6cdcf9ed.chunk.js:1:8467)
at p (about:blank:1:526)
at Object.310 (/static/js/main.6cdcf9ed.chunk.js:1:7943)
at p (about:blank:1:526)
at l (about:blank:1:387)
Error: Uncaught [Error: ]
at reportException (/apps/PG/project/PG/blog/node_modules/jsdom/lib/jsdom/living/helpers/runtime-script-errors.js:62:24)
at processJavaScript (/apps/PG/project/PG/blog/node_modules/jsdom/lib/jsdom/living/nodes/HTMLScriptElement-impl.js:243:7)
at HTMLScriptElementImpl._innerEval (/apps/PG/project/PG/blog/node_modules/jsdom/lib/jsdom/living/nodes/HTMLScriptElement-impl.js:168:5)
at onLoadExternalScript (/apps/PG/project/PG/blog/node_modules/jsdom/lib/jsdom/living/nodes/HTMLScriptElement-impl.js:90:12)
at onLoadWrapped (/apps/PG/project/PG/blog/node_modules/jsdom/lib/jsdom/browser/resources/per-document-resource-loader.js:53:33)
at Object.check (/apps/PG/project/PG/blog/node_modules/jsdom/lib/jsdom/browser/resources/resource-queue.js:76:23)
at /apps/PG/project/PG/blog/node_modules/jsdom/lib/jsdom/browser/resources/resource-queue.js:83:27 Error:
at XMLHttpRequest.send (/apps/PG/project/PG/blog/node_modules/jsdom/lib/jsdom/living/xmlhttprequest.js:616:17)
at s (/static/js/2.9369d994.chunk.js:1:1043462)
at H (/static/js/main.6cdcf9ed.chunk.js:1:3982)
at Object.156 (/static/js/main.6cdcf9ed.chunk.js:1:4104)
at p (about:blank:1:526)
at Module.775 (/static/js/main.6cdcf9ed.chunk.js:1:8467)
at p (about:blank:1:526)
at Object.310 (/static/js/main.6cdcf9ed.chunk.js:1:7943)
at p (about:blank:1:526)
at l (about:blank:1:387)
[ohshit] An error occured while building your app
Couldn't find window.NaviScripts - did you call register()?
Error: Couldn't find window.NaviScripts - did you call register()?
at crawl (/apps/PG/project/PG/blog/node_modules/navi-scripts/lib/crawl.js:22:15)
at build (/apps/PG/project/PG/blog/node_modules/navi-scripts/lib/build.js:9:32)
at Command.<anonymous> (/apps/PG/project/PG/blog/node_modules/navi-scripts/bin/navi-scripts.js:89:7)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! blog@0.1.0 build: `react-scripts build && navi-scripts build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the blog@0.1.0 build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /apps/PG/.npm/_logs/2020-03-21T06_10_36_643Z-debug.log
Is there a solution to this? I am experiencing the same error with create-react-blog.
Same errors here with navi-scripts builds. I can get the base blog to build, but when I try to link to a post or refresh the page on a post, I get that the page isn't found because navi-build fails and I'm guessing then is unable to create the static html files.
I am running
Hello,
When trying to build my blog, I'm getting
[ohshit] An error occured while building your app Couldn't find window.NaviScripts - did you call register()? Error: Couldn't find window.NaviScripts - did you call register()? at crawl (D:\blogReact\node_modules\navi-scripts\lib\crawl.js:22:15) at build (D:\blogReact\node_modules\navi-scripts\lib\build.js:9:32) at Command.<anonymous> (D:\blogReact\node_modules\navi-scripts\bin\ navi-scripts.js:89:7)
I have register in my index.js file. I have build the website before on another machine and it was working.
navi version: 0.12.6 navi-scripts version: 0.12.4
Any ideas what can be causing this?