脚本宝典收集整理的这篇文章主要介绍了NPM入门笔记,脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。
参考资料
网上普遍都是命令行的使用入门教程, 对于各种概念不解释,好不容易找到一个国外的:https://www.sitepoint.com/beg...
但是国内因为墙的问题, 连不上服务器, 所以还需要一个国内镜像:http://ju.outofmemory.cn/entr...
NPM是啥
安装
安装Node
速度非常快,完全不像国外的网站
windows, linux, 32/65bIT, 各个版本齐全
验证成功:
node --version
Node命令的语法跟通常有点不同, 首先,参数都是加两个-的, 其次, 命令以.开头,比如:
$ node
> console.log('Node is running');
Node is running
> .help
.break Sometimes you get stuck, this gets you out
.clear Alias for .break
.exit Exit the repl
.help Show repl options
.load Load JS from a file into the REPL session
.save Save all evaluated commands in this REPL session to a file> .exit
安装NPM
Node装完以后, npm连带着就装上了, 可以直接验证
$ npm --version
安装软件包
教程里关于默认位置和参数的修改,就直接跳过了, 先尝试使用
先尝试简单的安装
npm install uglify-js --global
发现默认源安装好慢,简直无法容忍,还是换一个吧,淘宝有国内镜像:
https://npm.taobao.org/
安装方式:
npm install -g cnpm --registry=https://registry.npm.taobao.org
以后就使用cnpm来代替npm了
再次尝试原来的命令
cnpm install uglify-js --global
迅速完成
本地安装: npm最好的地方在于, 缺省情况下(不带--global参数), 是安装到本地文件夹的.
npm install underscore
查看本地安装包: npm list
发现cnpm不是万能的, 刚才的underscore就,没有, 拿Vue来练手倒是成功了
npm install vue
以上是脚本宝典为你收集整理的NPM入门笔记全部内容,希望文章能够帮你解决NPM入门笔记所遇到的问题。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。