Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to use npm scripts in codesandbox.io?

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?

like image 721
Shankar Ganesh Jayaraman Avatar asked Apr 18 '20 10:04

Shankar Ganesh Jayaraman


People also ask

How do I use dependencies in CodeSandbox?

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.

Is there a terminal in CodeSandbox?

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.

What editor does CodeSandbox use?

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.


1 Answers

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

like image 143
Gareth Avatar answered Sep 27 '22 21:09

Gareth