I just tried to create a new Scaffold component but when run for example: npm run scaffold -- MyComponent, i receive Cannot find module './scaffold-component.ts' Require stack:.

Any idea to fix it? Thank you.

[email protected] scaffold

ts-node --project tsconfig.scripts.json scripts/scaffold-component.ts MyComponent

node:internal/modules/cjs/loader:1080 throw err; ^

Error: Cannot find module './scaffold-component.ts'

2 Answers 2


Please check if scaffold-component.ts is present in your application under Scripts (scripts/scaffold-component.ts) folder. This scaffold file is to use for creating the new components. Before creating a component, you must check whether the NextJs application is running properly. Use npm run start:connected to run the NextJS application. If the application is running properly, please try to scaffold new component- npm run scaffold -- MyComponent



The issue I found with this is related to the path of scaffold-component script. The path provided in sxastarter project's package.json is incorrect. There actually is no file called scaffold-component.ts within scripts folder. Check the folder structure below.

Scripts folder structure


To resolve the path, update the following line within your package.json enter image description here


"scaffold": "ts-node --project tsconfig.scripts.json scripts/scaffold-component/index.ts"

Which now will have the correct path.

You should now be able to run jss scaffold MyComponent or npm run scaffold -- MyComponent

Hope this helps.

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.