Giter Site home page Giter Site logo

generatefile_lesson3's Introduction

A guide to creating NodeJs commands-line package

  • Các bước tạo

    • Bước 1:Tạo gói NodeJs.js npm init

    • Bước 2 Tạo tập lệnh dòng lệnh NodeJS Bạn có thể đã biết rằng chúng ta có thể thực thi tệp tập lệnh NodeJS bằng cách chạy: . Điều đó là tốt trong hầu hết các trường hợp, nhưng tập lệnh dòng lệnh NodeJS là một tệp JavaScript thông thường, ngoại trừ việc nó chứa một lệnh shell đặc biệt. Thông tin thêm về điều đó trong thời gian ngắn; trước tiên chúng ta hãy tạo một tệp JavaScript sẽ trở thành tập lệnh dòng lệnh NodeJS.node script.js

      Trong file generate thêm dòng này vào dòng đầu tiên của file

      #!/usr/bin/env node

    • Bước 3: Thêm dòng này trong file package.json

    • Bước 4: Trong Node.js, npm link là một công cụ được sử dụng để liên kết một package được phát triển cục bộ với một ứng dụng hoặc package khác trên cùng một máy tính. Nó cho phép bạn phát triển các package một cách độc lập trên một thư mục và sử dụng chúng trong các ứng dụng khác mà không cần phải đăng ký và cài đặt chúng từ npm registry. chạy.

      chạy lệnh như sau để cài:

      npm link

      npm link bin package.json npm link npm link

Sau khi thiết lập xong có thể chạy dòng lệnh nodejs với tên của nó

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.