codesandbox / codesandbox-client

An online IDE for rapid web development
https://codesandbox.io
Other
13.13k stars 2.3k forks source link

Opening a terminal #1608

Closed neunygph closed 5 years ago

neunygph commented 5 years ago

Hi, I'm new to codesandbox and I"m wondering how to open a terminal in order to run a npm command. I looked about my sandbox but I couldn't find any option to open a terminal.

Thanks,

lbogdan commented 5 years ago

Hey @neunygph , you can only open a terminal in a server sandbox, you can read this article for more info.

neunygph commented 5 years ago

Ah I see, thank you.

lbogdan commented 5 years ago

In other news, CodeSandbox Containers is out of beta as of today! 🙂

Closing this, if you're interested in more details about this feature, you can also find us on Spectrum .

zommerfelds commented 5 years ago

In case this helps anyone: to enable containers for an existing project you need to create a sandbox.config.json file with the following content before creating the sandbox:

{
  "template": "node"
}

I'm not sure if there is a way to change the sandbox once it's created.

djnorrisdev commented 5 years ago

Terminal is not showing up in codesandboxes for me, and this is long after the containers update. How can I get a terminal in a sandbox now?

lbogdan commented 5 years ago

Hey @djnorrisdev ,

In order to open a terminal you need a server sandbox that you own - meaning that you created it by forking an existing sandbox / template (as a note, you don't own GitHub imported sandboxes, even if you own the repository).

For example, go to the node template - https://codesandbox.io/s/node , fork it, and to open a terminal, press on the right + icon in the "Terminal" pane:

image

lbogdan commented 5 years ago

@zommerfelds

I'm not sure if there is a way to change the sandbox once it's created.

There isn't one for now, but it's definitely high up on our roadmap!

djnorrisdev commented 5 years ago

@Ibogdan,

Thanks, I was trying to get access to be able to npm or yarn install a privately hosted npm package. I’m guessing that’s not possible yet?

JoeEarly commented 3 years ago

Any update on this, especially Terminal access on imported GitHub projects? Surely if I import my own GitHub project I should have the ability to run npm/yarn commands from a terminal window.

garethx commented 3 years ago

@JoeEarly You can already use a terminal on imported GitHub projects and do that - it's just that the terminal is only available to container sandboxes - See https://codesandbox.io/docs/environment for more info.

JoeEarly commented 3 years ago

@garethx I imported a GitHub project last night and it seems to have defaulted to client. How do I ensure an imported github project starts as a Container? Your link stats Currently it is not possible to convert a Client Sandbox to a Container Sandbox.

lbogdan commented 3 years ago

Hey @JoeEarly ,

You can add a sandbox.config.json to the root of the repository with the contents:

{
  "template": "node"
}

Example: https://github.com/lbogdan/csb-vue-vite/blob/master/sandbox.config.json (that's using the nuxt template, which is also a container template, and there's also next, which is useful for React / Next apps).

JoeEarly commented 3 years ago

Ok tried that but for some reason using the CodeSandbox UI, I don't have a node option in the dropdown and when editing with the editor, placing in node, it has no effect.

lbogdan commented 3 years ago

You can't change non-GitHub imported sandboxes between client and container environments. In case of GitHub imported sandboxes, adding the sandbox.config.json file and re-importing the repo should update the sandbox environment.

tatethurston commented 3 years ago

You can't change non-GitHub imported sandboxes between client and container environments. In case of GitHub imported sandboxes, adding the sandbox.config.json file and re-importing the repo should update the sandbox environment.

How do you re-import the repo?

alexnitta commented 3 years ago

I think "re-import the repo" really means add the sandbox.config.json file to the repo, delete the original sandbox, create a new one, and then import the repo.

Steps that worked for me to ensure that a sandbox has a terminal:

  1. Add sandbox.config.json to the root of the GitHub repo with the contents:
    {
        "template": "node"
    }

    Make sure this change is pushed up to the GitHub repo before you proceed.

  2. Create a new sandbox, select Import Project at the left and paste in the URL of the GitHub repo, then click Import and Fork.
  3. There should now be a terminal available in the tools in the lower right pane, showing that you're in a Container environment.
Samia1117 commented 3 years ago

But I get a -- 502: Bad Gateway -- and the container fails to start. Followed the 3 steps detailed by alexnitta above

tresabhi commented 3 years ago

@alexnitta Thanks, it works! It's quite sad that I'll now have to migrate sandboxes, but oh well.

didymus707 commented 2 years ago

Is it possible to add a terminal to an existing react codesandbox?

tresabhi commented 2 years ago

@didymus707 no 😔