Common JS methods are wrapped for use

Registration of NPM

www.npmjs.com/signup

Create an NPM Organization

www.npmjs.com/org/create

Create a common package with scope

  1. If you are using NPMRC to manage accounts on multiple registries, switch to the appropriate configuration file on the command line:
npmrc <profile-name>
Copy the code
  1. On the command line, create a directory for your package:
mkdir my-test-package
Copy the code
  1. Navigate to the package root directory:
cd my-test-package
Copy the code
  1. In the package root directory, run the NPM init command and pass the scope flag:
git init
git remote add origin git://git-remote-url
Copy the code
  1. Respond to prompts to generate package.json files. For help in naming packages, see Package Name Guidelines.
  • For organization-wide packages, replace my-org with your organization name:
npm init --scope=@my-org
Copy the code
  • For user-scoped packages, replace my-username with your username:
npm init --scope=@my-username
Copy the code
  1. Create a README file that explains what your package code is and how to use it.

Public packages in the distribution scope

npm publish --access public
Copy the code

Check the NPM

Used in React projects

import './App.css';

import zoina from '@tufuwd/my-test-package'

function App() {
  zoina()
  console.log(zoina.default(3.6))
  console.log(zoina.trim('Legendary pirate Gail D. Roger left a message about his life's treasure, "One Pi Ece," before he died.'))
  return (
    <div className="App">
      react
    </div>
  );
}

export default App;
Copy the code

preview