Skip to main content

npm2yarn

Example

If you want this Tabs behavier:

npm install @docusaurus/remark-plugin-npm2yarn

Without annoying coding, you need to install npm2yarn plugin. It transforms npm bash command code blocks to Docusaurus tabs.

note

It only works when used with Docusaurus themes that have the Tabs and TabItems components.

Install

Run this command to install the plugin:

npm install @docusaurus/remark-plugin-npm2yarn

Setup

Add the following three lines to docusaurus.config.js file:

docusaurus.config.js
module.exports = {
presets: [
[
'@docusaurus/preset-classic',
{
docs: {
// ...
remarkPlugins: [[require('@docusaurus/remark-plugin-npm2yarn'), {sync: true}]],
},
blog: {
// ...
remarkPlugins: [[require('@docusaurus/remark-plugin-npm2yarn'), {sync: true}]],
},
pages: {
// ...
remarkPlugins: [[require('@docusaurus/remark-plugin-npm2yarn'), {sync: true}]],
},
// ...
},
],
],
// ...
};

Usage

Copy this code:

```bash npm2yarn
npm install @docusaurus/remark-plugin-npm2yarn
```

and past it in your Markdown document to see plugin in action.

Cache

If your code doesn't work, you may need to clear the cache.

Clear Cache

npm run clear

and then run dev server again:

npm run start

to check if the plugin is working.