摘要:分钟搞定模块开发创建组建新建目录初始化创建新建测试文件大家好,我是春哥,我的电话是执行大家好,我是春哥,我的电话是发布到去官网注册一个自己的开发账号到注册账号记住自己的账号,密码,邮箱。
3分钟搞定NPM模块开发 创建组建 新建目录
localhost:Desktop yuechunli$ pwd /Users/liyuechun/Desktop localhost:Desktop yuechunli$ mkdir liyc_hello localhost:Desktop yuechunli$ cd liyc_hello/初始化
localhost:liyc_hello yuechunli$ npm init This utility will walk you through creating a package.json file. It only covers the most common items, and tries to guess sensible defaults. See `npm help json` for definitive documentation on these fields and exactly what they do. Use `npm install创建index.js--save` afterwards to install a package and save it as a dependency in the package.json file. Press ^C at any time to quit. name: (liyc_hello) version: (1.0.0) description: entry point: (index.js) test command: git repository: keywords: author: license: (ISC) About to write to /Users/liyuechun/Desktop/liyc_hello/package.json: { "name": "liyc_hello", "version": "1.0.0", "description": "", "main": "index.js", "scripts": { "test": "echo "Error: no test specified" && exit 1" }, "author": "", "license": "ISC" } Is this ok? (yes) localhost:liyc_hello yuechunli$
function print_liyc_hello(name) { console.log(name); } exports.print_liyc_hello = print_liyc_hello;新建测试文件test.js
var fn = require("./index.js"); fn.print_liyc_hello("大家好,我是春哥,我的电话是13331184066");执行test
localhost:liyc_hello yuechunli$ pwd /Users/liyuechun/Desktop/liyc_hello localhost:liyc_hello yuechunli$ ls index.js package.json test.js localhost:liyc_hello yuechunli$ node test 大家好,我是春哥,我的电话是13331184066 localhost:liyc_hello yuechunli$发布到NPM 去官网注册一个自己的开发账号
到https://www.npmjs.com注册账号,记住自己的账号,密码,邮箱。
命令行连接NPMlocalhost:liyc_hello yuechunli$ npm adduser Username: liyuechun Password: Email: (this IS public) liyuechun2009@163.com Logged in as liyuechun on https://registry.npmjs.org/. localhost:liyc_hello yuechunli$ npm whoami liyuechun localhost:liyc_hello yuechunli$发布
localhost:liyc_hello yuechunli$ npm publish + liyc_hello@1.0.0 localhost:liyc_hello yuechunli$使用 创建React 项目
localhost:Desktop yuechunli$ mkdir liycDemo localhost:Desktop yuechunli$ cd liycDemo/ localhost:liycDemo yuechunli$ create-react-app testApp Creating a new React app in /Users/liyuechun/Desktop/liycDemo/testApp. Installing packages. This might take a couple minutes. Installing react-scripts... npm WARN prefer global marked@0.3.6 should be installed with -g > fsevents@1.0.17 install /Users/liyuechun/Desktop/liycDemo/testApp/node_modules/fsevents > node-pre-gyp install --fallback-to-build [fsevents] Success: "/Users/liyuechun/Desktop/liycDemo/testApp/node_modules/fsevents/lib/binding/Release/node-v51-darwin-x64/fse.node" is installed via remote testApp@0.1.0 /Users/liyuechun/Desktop/liycDemo/testApp └─┬ react-scripts@0.9.2 ├─┬ autoprefixer@6.7.2 │ ├─┬ browserslist@1.7.5 │ │ └── electron-to-chromium@1.2.4 │ ├── caniuse-db@1.0.30000628 │ ├── normalize-range@0.1.2 │ ├── num2fraction@1.2.2 │ ├─┬ postcss@5.2.15 │ │ └── js-base64@2.1.9 │ └── postcss-value-parser@3.3.0 Success! Created testApp at /Users/liyuechun/Desktop/liycDemo/testApp Inside that directory, you can run several commands: npm start Starts the development server. npm run build Bundles the app into static files for production. npm test Starts the test runner. npm run eject Removes this tool and copies build dependencies, configuration files and scripts into the app directory. If you do this, you can’t go back! We suggest that you begin by typing: cd testApp npm start Happy hacking!项目结构图 安装 liyc_hello
localhost:liycDemo yuechunli$ ls testApp localhost:liycDemo yuechunli$ cd testApp/ localhost:testApp yuechunli$ atom ./ localhost:testApp yuechunli$ npm install --save liyc_hello testApp@0.1.0 /Users/liyuechun/Desktop/liycDemo/testApp └── liyc_hello@1.0.0 localhost:testApp yuechunli$安装后package.json内容变化 联系我
微信&微信: 13331184066
文章版权归作者所有,未经允许请勿转载,若此文章存在违规行为,您可以联系管理员删除。
转载请注明本文地址:https://www.ucloud.cn/yun/83818.html
摘要:你只要算好各种食材的比例,不用关心做菜的过程,就是那个微波炉。项目搭建步骤官网官网开发环境安装配置项目配置如图所示运行项目开发编译在浏览器输入看到,就跑通了。从基础开始,循序渐进,含有常用实战项目,贴近企业真实现状。 用一个完成的Vue系列文章,让大家全面理解Vue的实现原理,掌握实用技巧,能在实战中使用Vue,解锁一个开发技能。文末有文章大纲请查看。不墨迹了!马上写内容: 1.为什...
摘要:下载地址安装一个好用的命令行工具在环境下,系统默认的非常难用,所以我个人比较推荐大家使用或者。下载地址安装在命令行工具中使用查看版本的方式确保与都安装好之后,我们就可以安装了。前端基础进阶系列目录 showImg(https://segmentfault.com/img/remote/1460000009654403?w=1240&h=272); 对于新人朋友来说,想要自己去搞定一个E...
摘要:在终端中使用可以自动创建这个文件输入这个命令后,终端会问你一系列问题。百度后发现引入了模式,有三个状态,开发模式生产模式无。 什么是webpack,为什么要使用webapck * 导语 之前一直忙着项目,没时间整理自己的东西,最近刚好发现自己对webpack又如此陌生了,于是整理了一篇关于webpack初探的干货,这里是一点简单的webpack配置 为什么使用webpck 现今很多网页...
摘要:这些特性不仅带来了大的性能提升,还减少多线程程序设计的复杂性,进而提高了开发效率。由公司建立的云计算平台率先支持了。 前言 本文章主要写给那些想了解node语言的开发,我的目标希望大家通过阅读本篇文章能够简单使用node进行开发,以及了解一些事件驱动的异步编程风格,主要分node的背景,安装配置,模块创建引用等几个方面描述 建议大家在阅读本篇文章途中 可以亲自尝试一下我所带来的小例子,...
阅读 2453·2021-11-16 11:45
阅读 2422·2021-10-11 10:59
阅读 2233·2021-10-08 10:05
阅读 3722·2021-09-23 11:30
阅读 2331·2021-09-07 09:58
阅读 754·2019-08-30 15:55
阅读 750·2019-08-30 15:53
阅读 1905·2019-08-29 17:00