I am trying to run json-server
npm in codesandbox. I have created a vanilla project and added a dependency to the package.json
. I have to run a script with json-server --watch db.json
.
Is there a way in codesandbox to run the script?
Under the Dependencies tab in the File Editor section is a big, blue button -- Add Dependency. That button pops open a search modal that allows you to find packages from the npm registry. Start typing day. js and it will quickly show up as one of the results.
One of the benefits of working on CodeSandbox Repositories is running the terminal without ever leaving the Web Editor. The Terminal DevTool is connected to a Virtual Machine and behaves like your local terminal, accepting any commands you are used to running, such as: git operations. bash scripts.
CodeSandbox works with JavaScript (including TypeScript) and has front-end and full-stack support. We've client templates for: React, Vue, Angular, Preact, Svelte, Dojo, CX, Reason, as well as vanilla JavaScript that uses Parcel, and one for static (HTML, JavaScript, CSS) projects.
You'll need to use a container sandbox like Node in order to be able to both run json-server and set your own scripts.
Here's more info on the different types of sandboxes available on CodeSandbox: https://codesandbox.io/docs/environment
Incidentally, we have a json-server template you might be interested in: https://codesandbox.io/s/json-server-1i5z0
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With