First, create a new Sitecore instance with JSS installed to it.
Hostname: ocnext-jss.dev.local
Add site binding to the Sitecore instance:
Able to login with the new binding:
Create NextJS API Key:
Now, it is time to connect the disconnected application to the Sitecore instance (created above).
Go to the original folder where your disconnected instance is hosted and run jss setup (the place where you executed jss start):
End-result of jss setup:
scjssconfig.json
Executing jss deploy config, copies over config files from disconnected instance to the Sitecore instance:
Deploy items from disconnected instance to the Sitecore instance:
End-result:
Now, from the client folder, you can execute jss start:connected. Any publish from the CM instance will reflect in the newly connected NextJS instance.
Message:
JSS CLI is running in global mode because it was not installed in the local node_modules folder.
Reason: You probably are running jss setup one-level above the folder where nextjs is deployed or package.json is present!
Error:
Error: EPERM: operation not permitted, unlink 'C:\inetpub\wwwroot\sc102tstxsc.dev.local\App_Config\Include\zzz\ocnext-jss-app.config'
at Object.unlinkSync (node:fs:1735:3)
at mayCopyFile (C:\gitrepo\sitecore-jss\next\nextjs\node_modules\fs-extra\lib\copy-sync\copy-sync.js:59:8)
at onFile (C:\gitrepo\sitecore-jss\next\nextjs\node_modules\fs-extra\lib\copy-sync\copy-sync.js:54:10)
at getStats (C:\gitrepo\sitecore-jss\next\nextjs\node_modules\fs-extra\lib\copy-sync\copy-sync.js:48:44)
at startCopy (C:\gitrepo\sitecore-jss\next\nextjs\node_modules\fs-extra\lib\copy-sync\copy-sync.js:38:10)
at copyDirItem (C:\gitrepo\sitecore-jss\next\nextjs\node_modules\fs-extra\lib\copy-sync\copy-sync.js:120:10)
at C:\gitrepo\sitecore-jss\next\nextjs\node_modules\fs-extra\lib\copy-sync\copy-sync.js:113:39
at Array.forEach (<anonymous>)
at copyDir (C:\gitrepo\sitecore-jss\next\nextjs\node_modules\fs-extra\lib\copy-sync\copy-sync.js:113:23)
at onDir (C:\gitrepo\sitecore-jss\next\nextjs\node_modules\fs-extra\lib\copy-sync\copy-sync.js:103:10) {
errno: -4048,
syscall: 'unlink',
code: 'EPERM',
path: 'C:\\inetpub\\wwwroot\\sc102tstxsc.dev.local\\App_Config\\Include\\zzz\\ocnext-jss-app.config'
}
Cause: Cmd Prompt must be run in Administrator mode.
Error:
Unexpected error processing reply from import status service: TypeError: Cannot read properties of undefined (reading 'forEach')
Response: Job started: JSSImport-ocnext-jss-6:32:19 PM,#Exception: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.IO.FileNotFoundException: Could not load file or assembly 'Sitecore.Zip, Version=12.2.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.
at Sitecore.JavaScriptServices.AppServices.ImportService.ImportJob.StartImportInternal()
--- End of inner exception stack trace ---
at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at Sitecore.Reflection.ReflectionUtil.InvokeMethod(MethodInfo method, Object[] parameters, Object obj)
at Sitecore.Jobs.JobRunner.RunMethod(JobArgs args)
at (Object , Object )
at Sitecore.Pipelines.CorePipeline.Run(PipelineArgs args)
at Sitecore.Pipelines.DefaultCorePipelineManager.Run(String pipelineName, PipelineArgs args, String pipelineDomain, Boolean failIfNotExists)
at Sitecore.Pipelines.DefaultCorePipelineManager.Run(String pipelineName, PipelineArgs args, String pipelineDomain)
at Sitecore.Jobs.DefaultJob.DoExecute()
at Sitecore.Abstractions.BaseJob.ThreadEntry(Object state)
Consult the Sitecore logs for details.
TypeError: Cannot read properties of undefined (reading 'forEach')
at C:\gitrepo\sitecore-jss\next\jss\nextjs\node_modules\@sitecore-jss\sitecore-jss-dev-tools\dist\cjs\package-deploy.js:192:34
at processTicksAndRejections (node:internal/process/task_queues:96:5)
Reference:
https://doc.sitecore.com/xp/en/developers/hd/190/sitecore-headless-development/walkthrough--connecting-a-jss-application-to-sitecore.html
https://thedebugdude.com/creating-sitecore-next-js-app-in-connected-mode/
Comments
Post a Comment