[Whole Web] [Node.js] Using npm run to launch local scripts
npm run
allows you to configure scripts inside of your package.json
file which can access locally installed node packages. If you're comfortable with this technique, you can also grunt, gulp, or other build tools by customizing your scripts and saving them inside of your package.json
file. With this approach, when a developer starts a new project with your package.json
, they can simply runnpm install
then npm run yourscript
without having to install any node packages globally.
For example:
If you haven't installed browserify globally, and you use npm to install it locallly:
npm install browserify --save-dev
Then you create a test script to run browserify:
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"demo": "echo Hello World!",
"b_version": "browserify -v"
},
You run on tml:
npm run b_version
You will get the version number, but if you type in tml:
browserify -v
You will get error, because you haven't installed it globally, which means that I can use npm run to invoke anything I've installed locally without forcing my users to say "npm install -g" to install things globally, Which means with this approach, you could just include a package file in your project, say "npm install" to get everything installed locally, and then npm run whatever task you want to set up, whether it's browserify or whatever. Then it can just grab those locally installed modules and run them.
More:
https://egghead.io/lessons/nodejs-using-npm-run-to-launch-local-scripts#/tab-transcript
[Whole Web] [Node.js] Using npm run to launch local scripts的更多相关文章
- node ***.js或npm run scripts的脚本命令出现Cannot find module 'react-dev-utils/getPublicUrlOrPath'报错的解决办法
出现类似Cannot find module 'react-dev-utils/getPublicUrlOrPath'一般是项目中没有下载报错中提到的模块(可以在项目中package.json文件de ...
- how to updating Node.js and npm
how to updating Node.js and npm 1 Installing Node.js and updating npm How do I update Node.js ? Not ...
- 安装node.js 和 npm 的完整步骤
vue 生命周期 1,beforeCreate 组件刚刚被创建 2,created 组件创建完成 3,beforeMount 挂载之前 4,mounted 挂载之后 5,beforeDestory 组 ...
- 如何在CentOS 7上安装Node.js和npm
Node.js是一个跨平台的JavaScript运行时环境,允许在服务器端执行JavaScript代码.Node.js主要用于后端,但也作为全栈和前端解决方案而流行. npm,Node软件包管理器的缩 ...
- 【强烈推荐,超详细,实操零失误】node.js安装 + npm安装教程 + Vue开发环境搭建
node.js安装 + npm安装教程 + Vue开发环境搭建 [强烈推荐,超详细,实操零失误] 原博客园地址:https://www.cnblogs.com/goldlong/p/8027997.h ...
- nuxt.js 初始化 npm run dev 报错
在初始化 npm install 了基本依赖后: npm run dev 报错: error in ./server/index.js Module build failed: Error: Plug ...
- Vue项目一、node.js和npm的安装和环境搭建
一.为什么安装node.js及npm npm npm是Node.js的包管理工具(package manager),是全球最大的生态系统,同过npm可以找到很多丰富的插件来满足项目的需求. a1.现在 ...
- 在Linux Mint上安装node.js和npm
1.安装Node.js 前端开发过程中,很多项目使用npm的http-server的模块来运行一个静态的服务器,我个人在Dell的笔记本上安装的是Linux Mint最新版本,所以想尝试一下在Linu ...
- 关于node.js和npm,cnpm的安装记录以及gulp自动构建工具的使用
关于node.js和npm,cnpm的安装记录以及gulp自动构建工具的使用 工作环境:window下 在一切的最开始,安装node.js (中文站,更新比较慢http://nodejs.cn/) ...
随机推荐
- linux shell if 参数
shell 编程中使用到得if语句内判断参数 –b 当file存在并且是块文件时返回真 -c 当file存在并且是字符文件时返回真 -d 当pathname存在并且是一个目录时返回真 -e 当path ...
- table点击一行显示下一行的特效
效果体验:http://sandbox.runjs.cn/show/rw4vq8zo <!doctype html> <html> <head> <meta ...
- SharePoint 2010 master page 控件介绍(5):其他
转:http://blog.csdn.net/lgm97/article/details/6409227 <!-- 处理搜索按下"enter"键和点击后退按钮 --> ...
- WCF配置文件详解(一)
<?xml version="1.0" encoding="utf-8" ?><configuration> <!-- &l ...
- [转] 三种Python下载url并保存文件的代码
原文 三种Python下载url并保存文件的代码 利用程序自己编写下载文件挺有意思的. Python中最流行的方法就是通过Http利用urllib或者urllib2模块. 当然你也可以利用ftplib ...
- C# using SendMessage, problem with WM_COPYDATA z
The final missing piece depends on if you are using any processor, x86 or x64. The details using the ...
- HDU 1078 FatMouse and Cheese 记忆化搜索DP
直接爆搜肯定超时,除非你加了某种凡人不能想出来的剪枝...555 因为老鼠的路径上的点满足是递增的,所以满足一定的拓补关系,可以利用动态规划求解 但是复杂的拓补关系无法简单的用循环实现,所以直接采取记 ...
- temorrow read
http://blog.csdn.net/yimiyangguang1314/article/details/6268177 http://www.cnblogs.com/killmyday/arch ...
- activemq 一个不错的ppt
http://people.apache.org/~jstrachan/talks/ActiveMQ-Dublin07.pdf
- bzoj 3198 [Sdoi2013]spring(容斥原理+Hash)
Description Input Output Sample Input 3 3 1 2 3 4 5 6 1 2 3 0 0 0 0 0 0 4 5 6 Sample Output 2 HINT [ ...