Here's a step-by-step guide to get you started with `cnsh`:
Install `cnsh` globally using npm:
npm install -g cnsh --verbose
Use the following commands to add or remove packages:
cnsh add [package]
cnsh remove [package]
cnsh add -g [package]
cnsh remove -g [package]
To install all dependencies listed in your `package.json`, use:
cnsh install
Here’s how you can use an installed package in your project:
async function fetchData() {
try {
const axios = await import('./cnsh_lib/axios/package/dist/esm/axios.min.js');
const response = await axios.default.get('https://jsonplaceholder.typicode.com/posts/1');
console.log('Data fetched:', response.data);
} catch (error) {
console.error('Error fetching data:', error);
}
}
fetchData();
If you encounter any issues, check the common problems and solutions below: