chore: reorganize docs apps (#7228)

* reorganize docs apps

* add README

* fix directory

* add condition for old docs
This commit is contained in:
Shahed Nasser authored and GitHub committed 2024-05-03 17:36:38 +03:00
1 parent 224ebb2154
commit 4fe28f5a95
6187 files changed
+601447 -598226

No files matched your search

@@ -0,0 +1,3 @@
If you install the Medusa CLI tool with NPM and get a permission error, NPM proposes as a solution either re-installing NPM with a node version manager (nvm), or manually setting npm’s default directory.
Learn more in [NPM’s documentation](https://docs.npmjs.com/resolving-eacces-permissions-errors-when-installing-packages-globally).
@@ -0,0 +1,7 @@
If you're using Powershell and you installed the CLI tool, but when you try to use it you get the error:
```bash noReport
command not found: medusa
```
Try closing your Powershell window and opening a new one.
@@ -0,0 +1,21 @@
import { DetailsList } from "docs-ui"
import PermissionErrorsSection from './permission-errors.md'
import PowershellErrorSection from './powershell-error.md'
import YarnErrorSection from './yarn-error.mdx'
<DetailsList
sections={[
{
title: "NPM Error: EACCES Permissions Errors",
content: <PermissionErrorsSection />
},
{
title: "Powershell Error: command not found: medusa",
content: <PowershellErrorSection />
},
{
title: "Yarn Error: command not found: medusa",
content: <YarnErrorSection />
}
]}
/>
@@ -0,0 +1,35 @@
import { LegacyCodeTabs } from "docs-ui"
If you install the Medusa CLI tool with Yarn, then try to use the CLI tool but get the error:
```bash noReport
command not found: medusa
```
You have to add Yarn’s install location to the PATH variable:
<LegacyCodeTabs
tabs={[
{
label: "MacOS / Linux",
value: "unix",
code: {
lang: "bash",
source: `export PATH="$(yarn global bin):$PATH"`
}
},
{
label: "Windows",
value: "windows",
code: {
lang: "bash",
source: `# MAKE SURE TO INCLUDE %path%
setx path "%path%;c:\\users\\YOURUSERNAME\\appdata\\local\\yarnbin"
# YOURUSERNAME is your account username`
}
}
]}
group="operating-systems"
/>
You can learn more in [Yarn’s documentation](https://classic.yarnpkg.com/en/docs/cli/global#adding-the-install-location-to-your-path).
@@ -0,0 +1,26 @@
import { LegacyCodeTabs } from "docs-ui"
This error can occur while installing any of Medusa's projects (for example, Next.js Starter Template). There is no specific cause to this error.
One way to resolve it is by removing the `node_modules` directory in the project and re-installing the dependencies:
<LegacyCodeTabs tabs={[
{
label: "MacOS / Linux",
value: "unix",
code: {
lang: "bash",
source: `rm -rf node_modules
yarn install`
}
},
{
label: "Windows",
value: "windows",
code: {
lang: "bash",
source: `rd /s /q node_modules
yarn install`
}
}
]} group="operating-systems" />
@@ -0,0 +1,9 @@
If you use the `--db-url` option with the `create-medusa-app` command and the connection to the database fails, try the following:
- Specify `?sslmode=require` at the end of the connection URL. Some PostgreSQL hosting providers, like Vercel, require passing this option. For example:
```bash
npx create-medusa-app@latest --db-url "postgres://default:<password><host-region>.postgres.vercel-storage.com:5432/verceldb?sslmode=require"
```
- Change the password to remove special characters. PostgreSQL requires encoding passwords if they have special characters. While the `create-medusa-app` command handles this automatically when you specify the password to the `create-medusa-app` command, when you pass a connection URL with the `--db-url` the command uses that URL as-is. So, you must either encode the special characters in the password yourself, or remove the special characters in the password.
@@ -0,0 +1,39 @@
When using the `create-medusa-app` npx command, you might run into an NPM `EAGAIN` error. This error can randomly occur due to conflicting processes.
The easiest solution is to start the command over. Alternatively, if your setup crossed the "create database" point, you can manually perform the following steps in the directory of your created project. You can skip any steps that you're sure have been performed by `create-medusa-app`:
1. Install dependencies:
```bash npm2yarn
npm install
```
2. Build project:
```bash npm2yarn
npm run build
```
3. Run migrations:
```bash
npx medusa migrations run
```
4. Create an admin user:
```bash
npx medusa user -e user@test.com -p supersecret
```
5. Optionally seed the database:
```bash
npx medusa seed -f ./data/seed.json
```
6. Start project:
```bash
npx medusa develop
```
@@ -0,0 +1,13 @@
If you're running the Medusa backend through tools like VSCode or GitHub Codespaces, you must ensure that:
1. Port forwarding is configured for ports `9000` and `7001`. Refer to the following resources on how to configure forwarded ports:
- [VSCode local development.](https://code.visualstudio.com/docs/editor/port-forwarding)
- [VSCode remote development.](https://code.visualstudio.com/docs/remote/ssh#_forwarding-a-port-creating-ssh-tunnel)
- [GitHub Codespaces.](https://docs.github.com/en/codespaces/developing-in-a-codespace/forwarding-ports-in-your-codespace)
2. If your tool or IDE exposes an address other than `localhost`, such as `127.0.0.1`, make sure to add that address to the [admin_cors](/references/medusa-config) Medusa configuration. Your tool will show you what the forwarded address is.
After setting these configurations, run your Medusa backend and try again. If you couldn't create an admin user before, run the following command in the root directory of your Medusa project to create an admin user:
```bash
npx medusa user -e admin@medusa-test.com -p supersecret
```
@@ -0,0 +1,5 @@
If you use the `--no-browser` option with the `create-medusa-app` command, you'll find a URL outputted at the end of the command execution. This is the URL that you can use to set a password for your admin user.
However, if you copy the URL, then try later to access that URL, you may receive an "Invalid Token" error. This is because when you copy the URL, a lot of extra space may be added into the token. So, you must clear out the spaces within the token and the `||` characters, then try again.
Alternatively, you can create a new user with the [medusa user command](../../../medusa-cli/page.mdx#user).
@@ -0,0 +1,36 @@
import { Tabs, TabsList, TabsTrigger, TabsContent, TabsContentWrapper } from "docs-ui"
As a last resort to resolve your issue, please try to clear your `npx` cache, as it could hold a cached version of `create-medusa-app` with errors.
<Tabs defaultValue="unix">
<TabsList>
<TabsTrigger value="unix">MacOS / Linux</TabsTrigger>
<TabsTrigger value="windows">Windows</TabsTrigger>
</TabsList>
<TabsContentWrapper>
<TabsContent value="unix">
Run the following command:
```bash
rm -rf "$(npm config get cache)/_npx"
```
Try running the `create-medusa-app` command again.
</TabsContent>
<TabsContent value="windows">
First, find the cache directory with the following command:
```bash
npm config get cache
```
The npx cache should be in the directory `<NPM_CACHE>/_npx`, where `<NPM_CACHE>` is the cache directory returned by the previous command. Delete that directory and try running the `create-medusa-app` command again.
</TabsContent>
</TabsContentWrapper>
</Tabs>
If your issue persists, please try to search through [our GitHub issues](https://github.com/medusajs/medusa/issues) to see if there's a solution for your issue. If not, please [create an issue on GitHub](https://github.com/medusajs/medusa/issues/new?assignees=olivermrbl&labels=status:+needs+triaging,+type:+bug&template=bug_report.md&title=") and our team will help you resolve it soon."
@@ -0,0 +1,8 @@
This error typically occurs when you set up a Medusa project with `create-medusa-app` and try to run the Medusa backend.
To resolve this issue, make sure you change into the `backend` directory of the Medusa project you created before trying to start the Medusa backend:
```bash npm2yarn
cd backend
npx medusa develop
```
@@ -0,0 +1,10 @@
When you start your Medusa backend you may run into the following error:
```bash
Error: connect ECONNREFUSED ::1:5432
```
This error occurs because the backend couldn't connect to the PostgreSQL database. The issue could be one of the following:
1. PostgreSQL server isn't running. Make sure it's always running while the Medusa backend is running.
2. The connection URL to your PostgreSQL database is incorrect. This could be because of incorrect credentials, port number, or connection URL format. The format should be `postgres://[user][:password]@[host][:port]/[dbname]`. Make sure that the connection URL format is correct, and the credentials passed in the URL are correct. You can learn more about formatting the connection URL [here](/references/medusa-config#postgresql-configurations)
@@ -0,0 +1,25 @@
When connecting your Medusa backend to a PostgreSQL Docker container, make sure the `5432` port is exposed.
To do that, either pass the `-p` option to the `docker run` command. For example:
```bash
docker run -d -p 5432:5432 --name some-postgres -e POSTGRES_PASSWORD=supersecret postgres
```
Or, if you're using Docker Desktop, you can provide the option under the container's "Optional settings" collapsable.
![Setting Port option in Docker Desktop](https://res.cloudinary.com/dza7lstvk/image/upload/v1699952615/Medusa%20Docs/Screenshots/Screenshot_2023-11-14_at_10.56.04_AM_nsur0q.png)
If you expose the PostgreSQL docker container at a port other than `5432`, make sure to include it in your database URL.
When installing Medusa with `create-medusa-app`, you can provide a database URL with the different port using the `--db-url` option.
For example:
```bash
npx create-medusa-app@latest --db-url "postgres://user:password@localhost:<YOUR_PORT>/medusa-store"
```
Where `<YOUR_PORT>` is the exposed port if it's different than `5432`.
Refer to the [database_url configuration documentation](/medusa-configurations#database_url) to learn how to set the database URL for an installed Medusa backend.
@@ -0,0 +1,3 @@
The database user you use in the `database_url` Medusa backend configuration must have create privileges. Otherwise, you'll face problems when running migrations.
If you're using the `postgres` superuser, then it should have these privileges by default. Otherwise, make sure to grant your user create privileges. You can learn how to do that in [PostgreSQL's documentation](https://www.postgresql.org/docs/current/ddl-priv.html).
@@ -0,0 +1,18 @@
You may get the following error while running `medusa new`:
```bash
Error: SASL: SCRAM-SERVER-FIRST-MESSAGE: client password must be a string
```
If the error occurs while running `medusa new` and you've selected to enter your database credentials, either:
1. Make sure your database credentials are correct;
2. Or choose the Skip option to skip entering your database credentials.
If the error occurs while running integration tests, make sure the following variable is set in your system's environment variable:
```bash
DB_HOST=<YOUR_DB_HOST>
DB_USERNAME=<YOUR_DB_USERNAME>
DB_PASSWORD=<YOUR_PASSWORD>
```
@@ -0,0 +1,17 @@
By default, passing the `--with-nextjs-starter` to the `create-medusa-app` command starts both the Medusa application at `localhost:9000` and the Next.js Starter storefront at `localhost:8000` once the installation finishes successfully. The Medusa Admin also opens in your default browser.
If, while following along the setup process, you try to access the Next.js storefront and it's not working, try to run the storefront manually while the Medusa application is still running.
To do that, first, change to the directory of the storefront. The directory name is `{project_name}-storefront`, where `{project_name}` is the name you chose for the project while running the `create-medusa-app` command. For example:
```bash
cd my-medusa-store-storefront
```
Then, run the following command to start the storefront:
```bash npm2yarn
npm run dev
```
The storefront runs on `localhost:8000` now.
@@ -0,0 +1,21 @@
If you are experiencing connection issues when trying to access your Medusa backend from a storefront or the admin dashboard, it is most likely due to Cross-Origin Resource Sharing (CORS) issues.
You might see a log in your browser console, that looks like this:
![CORS error log](https://res.cloudinary.com/dza7lstvk/image/upload/v1668003322/Medusa%20Docs/Other/jnHK115_udgf2n.png)
In your `medusa-config.js` , you should ensure that you've configured your CORS settings correctly. By default, the Medusa starter runs on port `9000`, Medusa Admin runs on port `7001`, and the storefront starters run on port `8000`.
The default configuration uses the following CORS settings:
```js title="medusa-config.js"
// CORS when consuming Medusa from admin
const ADMIN_CORS = process.env.ADMIN_CORS ||
"http://localhost:7000,http://localhost:7001"
// CORS to avoid issues when consuming Medusa from a client
const STORE_CORS =
process.env.STORE_CORS || "http://localhost:8000"
```
If you wish to run your storefront or Medusa Admin on other ports, you should update the above settings accordingly.
@@ -0,0 +1,14 @@
When you run your backend you may run to an error similar to the following:
```bash
code: 'EADDRINUSE',
errno: -48,
syscall: 'Listen',
address: '::',
port: 9000
```
This means that there's another process running at port `9000`. You need to either:
- Change the default port used by the Medusa backend. You can do that by setting the `PORT` environment variable to a new port. When you do this, make sure to change the port used in other apps that interact with your Medusa backend, such as in your [admin](../admin/configuration.mdx#build-command-options) or [storefront](../starters/nextjs-medusa-starter.mdx#changing-medusa-backend-url).
- Terminate other processes running on port `9000`.
@@ -0,0 +1,14 @@
If you're using the [S3 Plugin](../../../plugins/storage/s3/page.mdx) and, when you upload an image, you receive the following error on your Medusa backend:
```bash noReport
AccessControlListNotSupported: The bucket does not allow ACLs
```
Try the following:
1. Go to your S3 Bucket, then choose the Permissions tab.
2. Scroll to Object Ownership and click the Edit button.
3. Select ACLs enabled and choose for Object Ownership the radio button Bucket owner preferred.
4. Click the Save Changes.
Try uploading again after making this change. Upload should be successful.
@@ -0,0 +1,18 @@
export const metadata = {
title: `Signing in to Medusa Admin`,
}
# {metadata.title}
If you've created a new Medusa backend and used the `seed` command, the default credentials are:
```bash noReport
email: admin@medusa-test.com
password: supersecret
```
Alternatively, you can create your own users using the Medusa CLI tool:
```bash
npx medusa user -e some@email.com -p somepassword
```
@@ -0,0 +1,93 @@
export const metadata = {
title: `Admin Webpack Build Error`,
}
# {metadata.title}
If you run the `build` command in your backend and you get an error message during the admin build process similar to the following:
```bash noReport noCopy
The left-hand side of an assignment expression must be a variable or a property access.
```
Make sure that in your admin customizations (widget, UI route, or settings page) you're not using a type imported from `@medusajs/medusa`.
This is often the case if you're using a type or an enum necessary for a request sent with the JS Client or Medusa React library.
For example:
```ts
import {
Region,
ShippingOptionPriceType,
} from "@medusajs/medusa"
import type Medusa from "@medusajs/medusa-js"
export default async function prepareShippingOptions(
client: Medusa,
region: Region
) {
let {
shipping_options,
} = await client.admin.shippingOptions.list({
region_id: region.id,
})
if (!shipping_options.length) {
shipping_options = [(
await client.admin.shippingOptions.create({
"name": "PostFake Standard",
"region_id": region.id,
"provider_id": "manual",
"data": {
"id": "manual-fulfillment",
},
// THIS CAUSES THE ERROR
"price_type": ShippingOptionPriceType.FLAT_RATE,
"amount": 1000,
}
)).shipping_option]
}
return shipping_options
}
```
In this case, you're using the `ShippingOptionPriceType` type to send a request with the JS Client.
Instead, change it to the string value. If you get a TypeScript error, you can add `// @ts-ignore` before the line:
```ts
import {
Region,
ShippingOptionPriceType,
} from "@medusajs/medusa"
import type Medusa from "@medusajs/medusa-js"
export default async function prepareShippingOptions(
client: Medusa,
region: Region
) {
let {
shipping_options,
} = await client.admin.shippingOptions.list({
region_id: region.id,
})
if (!shipping_options.length) {
shipping_options = [(
await client.admin.shippingOptions.create({
"name": "PostFake Standard",
"region_id": region.id,
"provider_id": "manual",
"data": {
"id": "manual-fulfillment",
},
// @ts-expect-error can't use type from core
"price_type": "flat_rate",
"amount": 1000,
}
)).shipping_option]
}
return shipping_options
}
```
@@ -0,0 +1,9 @@
import CorsErrorTroubleshooting from "../_sections/other/cors-errors.mdx"
export const metadata = {
title: `CORS Errors`,
}
# {metadata.title}
<CorsErrorTroubleshooting />
@@ -0,0 +1,46 @@
import TypeError from "../_sections/create-medusa-app-errors/typeerror.mdx"
import OtherErrors from "../_sections/create-medusa-app-errors/other-errors.mdx"
import InvalidTokenError from "../_sections/create-medusa-app-errors/no-browser-token-error.mdx"
import DockerSection from "../_sections/database-errors/docker.mdx"
import DbUrlError from "../_sections/create-medusa-app-errors/db-url-error.mdx"
import ForwardingError from "../_sections/create-medusa-app-errors/forwarding.mdx"
export const metadata = {
title: `Common Create-React-App Errors`,
}
# {metadata.title}
## TypeError: cmd is not a function
<TypeError />
---
## Errors when using VSCode or GitHub Codespaces
<ForwardingError />
---
## Invalid Token Error with --no-browser Option
<InvalidTokenError />
---
## Can't Connect to PostgreSQL Docker Container
<DockerSection />
---
## Can't connect to database with --db-url option
<DbUrlError />
---
## Other Errors
<OtherErrors />
@@ -0,0 +1,32 @@
import SaslSection from '../_sections/database-errors/sasl.mdx'
import ConnectionErrorSection from '../_sections/database-errors/connection-error.mdx'
import PrivilegesSection from '../_sections/database-errors/privileges.mdx'
import DockerSection from "../_sections/database-errors/docker.mdx"
export const metadata = {
title: `Database Errors`,
}
# {metadata.title}
## Can't Connect to PostgreSQL Docker Container
<DockerSection />
---
## Error: SASL: SCRAM-SERVER-FIRST-MESSAGE: Client password must be a string
<SaslSection />
---
## Error: connect ECONNREFUSED ::1:5432
<ConnectionErrorSection />
---
## Database User Privileges
<PrivilegesSection />
@@ -0,0 +1,9 @@
import Eaddrinuse from "../_sections/other/eaddrinuse.mdx"
export const metadata = {
title: `EADDRINUSE Error`,
}
# {metadata.title}
<Eaddrinuse />
@@ -0,0 +1,17 @@
export const metadata = {
title: `Errors After Upgrading`,
}
# {metadata.title}
{/* TODO add link [Upgrade Guides](../upgrade-guides/page.mdx) */}
If you run into errors after updating Medusa and its dependencies, it's highly recommended to check the Upgrade Guides if there is a specific guide for your version. These guides include steps required to perform after upgrading Medusa.
If there's no upgrade guide for your version, make sure that you ran the `migrations` command in the root directory of your Medusa backend:
```bash
npx medusa migrations run
```
This ensures your backend has the latest database structure required. Then, try running your Medusa backend again and check whether the same error occurs.
@@ -0,0 +1,27 @@
import PermissionErrorsSection from '../_sections/cli-installation-errors/permission-errors.mdx'
import PowershellErrorSection from '../_sections/cli-installation-errors/powershell-error.mdx'
import YarnError from '../_sections/cli-installation-errors/yarn-error.mdx'
export const metadata = {
title: `Resolve Errors Installing Medusa CLI`,
}
# {metadata.title}
In this document, you can find solutions to some common problems that occur when installing Medusa’s CLI Tool.
## NPM Error: EACCES Permissions Errors
<PermissionErrorsSection />
---
## Powershell Error: command not found: medusa
<PowershellErrorSection />
---
## Yarn Error: command not found: medusa
<YarnError />
@@ -0,0 +1,11 @@
import ModuleXErrorSection from '../_sections/common-installation-errors/module-x-error.mdx'
export const metadata = {
title: `General Errors`,
}
# {metadata.title}
## Resolve "Cannot find module X" Errors
<ModuleXErrorSection />
@@ -0,0 +1,9 @@
import { ChildDocs } from "docs-ui"
export const metadata = {
title: `Troubleshooting Guides`,
}
# {metadata.title}
<ChildDocs />
@@ -0,0 +1,30 @@
export const metadata = {
title: `Payment Provider not showing in checkout`,
}
# {metadata.title}
You add payment providers to your Medusa instance by adding them as plugins in `medusa-config.js`:
```js title="medusa-config.js"
const plugins = [
// ...
{
resolve: `medusa-payment-stripe`,
options: {
api_key: STRIPE_API_KEY,
webhook_secret: STRIPE_WEBHOOK_SECRET,
},
},
]
```
And installing them with your favourite package manager:
```bash npm2yarn
npm install medusa-payment-stripe
```
However, to also show them as part of your checkout flow you need to add them to your regions.
Then, refer to this user guide to learn how to enable the [payment provider in a region](!user-guide!/settings/regions/providers).
@@ -0,0 +1,9 @@
import AclErrorSection from "../_sections/other/s3-acl.mdx"
export const metadata = {
title: `S3 Plugin ACL Error`,
}
# {metadata.title}
<AclErrorSection />
@@ -0,0 +1,22 @@
export const metadata = {
title: `Database Transaction Not Rolling Back When Promise.all is Used`,
}
# {metadata.title}
Due to how `Promise.all` works, when you run multiple database transactions within it, these transactions may not be rolled back when an error occurs.
To mitigate this issue, use the `promiseAll` function which can be imported from `@medusajs/utils`. For example:
```ts
import { promiseAll } from "@medusajs/utils"
import { TransactionBaseService } from "@medusajs/medusa"
class MyService extends TransactionBaseService {
async performTransactions() {
return await promiseAll([
// your transactions....
])
}
}
```