3

I'm following along with Discover Sitecore's "Build Your First JSS App" video (https://www.youtube.com/watch?v=XNQGsr9_34A) and was only 2:10 in when I ran into my first issue.
All I've done so far was install jss globally using the command
npm install -g @sitecore-jss/sitecore-jss-cli
and then I created a new jss app using this command
npm init sitecore-jss react
After cd to the new directory, I attempted to execute the command jss start when I got the errors indicated.

> npm run start --

> [email protected] start
> cross-env-shell JSS_MODE=disconnected "npm-run-all --serial bootstrap --parallel start:react start:proxy start:watch-components"


> [email protected] bootstrap
> cross-env-shell FETCH_WITH=GraphQL "node scripts/bootstrap.js"

C:\Projects\jss-react\scripts\bootstrap.js:15
  throw new Error(
  ^

Error: GraphQL requests to Dictionary and Layout services are not supported in disconnected mode.
    at Object.<anonymous> (C:\Projects\jss-react\scripts\bootstrap.js:15:9)
    at Module._compile (node:internal/modules/cjs/loader:1105:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1159:10)
    at Module.load (node:internal/modules/cjs/loader:981:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:77:12)
    at node:internal/main/run_main_module:17:47
node:events:505
      throw er; // Unhandled 'error' event
      ^

Error: spawn node scripts\bootstrap.js ENOENT
    at notFoundError (C:\Projects\jss-react\node_modules\cross-spawn\lib\enoent.js:6:26)
    at verifyENOENT (C:\Projects\jss-react\node_modules\cross-spawn\lib\enoent.js:40:16)
    at ChildProcess.cp.emit (C:\Projects\jss-react\node_modules\cross-spawn\lib\enoent.js:27:25)
    at Process.ChildProcess._handle.onexit (node:internal/child_process:291:12)
Emitted 'error' event on ChildProcess instance at:
    at ChildProcess.cp.emit (C:\Projects\jss-react\node_modules\cross-spawn\lib\enoent.js:30:37)
    at Process.ChildProcess._handle.onexit (node:internal/child_process:291:12) {
  code: 'ENOENT',
  errno: 'ENOENT',
  syscall: 'spawn node scripts\\bootstrap.js',
  path: 'node scripts\\bootstrap.js',
  spawnargs: []
}
ERROR: "bootstrap" exited with 1.
node:events:505
      throw er; // Unhandled 'error' event
      ^

Error: spawn npm-run-all --serial bootstrap --parallel start:react start:proxy start:watch-components ENOENT
    at notFoundError (C:\Projects\jss-react\node_modules\cross-spawn\lib\enoent.js:6:26)
    at verifyENOENT (C:\Projects\jss-react\node_modules\cross-spawn\lib\enoent.js:40:16)
    at ChildProcess.cp.emit (C:\Projects\jss-react\node_modules\cross-spawn\lib\enoent.js:27:25)
    at Process.ChildProcess._handle.onexit (node:internal/child_process:291:12)
Emitted 'error' event on ChildProcess instance at:
    at ChildProcess.cp.emit (C:\Projects\jss-react\node_modules\cross-spawn\lib\enoent.js:30:37)
    at Process.ChildProcess._handle.onexit (node:internal/child_process:291:12) {
  code: 'ENOENT',
  errno: 'ENOENT',
  syscall: 'spawn npm-run-all --serial bootstrap --parallel start:react start:proxy start:watch-components',
  path: 'npm-run-all --serial bootstrap --parallel start:react start:proxy start:watch-components',
  spawnargs: []
}

2 Answers 2

4

When you run this command npm init sitecore-jss react it ask some option one of them is How would you like to fetch Layout and Dictionary data? it have two types (GraphQL and Rest) as shown in below screenshot.

enter image description here

Please select Rest then it will start working because i think GraphQL doesn't supports in disconnected mode.

I tried it and it's started working, please see below screenshot

enter image description here

2
  • This did resolve the error so I will mark this as the answer, thank you. Do you have any info on how I would switch to connected mode with GraphQL?
    – Michael
    Commented Jun 1, 2022 at 14:46
  • Switching to GraphQL is now as simple as setting FETCH_WITH environment variable (used to be changing dictionary-service-factory.js and layout-service-factory.js). To switching to connected mode you just have to run jss setup and then jss start:connected. Switch between REST and GraphQL
    – Jason
    Commented Jun 24, 2022 at 9:45
2

Instead of executing npm init sitecore-jss react we can update the FETCH_WITH parameter in .env file because in Next.js Dictionary and Layout service factory have made an easy way to switch from disconnected to connected mode.

After that, when you will run jss start, your jss site will be up and running locally in disconnected mode.

1
  • Yes, this switching is definitely a better way than re-initializing a project
    – Felini
    Commented Feb 7, 2023 at 7:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.