Tooling with NPM Scripts

Using the exercises

1
2
3
4
5
6
7
8
9
mkdir npmtooling
cd npmtooling
git clone --bare https://github.com/planetoftheweb/npmtooling.git .git
git config --bool core.bare false
git reset --hard
npm install # install all of the project dependencies.
git branch # to see all the branches available
git checkout 03_01b
git stash && git checkout 03_01e # go ahead and ignore any of your changes

Getting Started

Creating a live server

1
2
3
4
5
npm install xxx
# If the application needs the package in order to run as part of the final product, then you can use dash dash save.
npm install <package>@<version> # install specified version
# You can also save it as a development dependency, which means that it's something that you only need to run during the development phase.
npm install --save-dev live-server

Managing script types

Create a command in package.json

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
{
"name": "npmTooling",
"version": "0.0.1",
"description": "Assets for my Tooling with NPM Scripts course at Lynda.com",
"repository": {
"type": "git",
"url": "https://github.com/planetoftheweb/npmtooling.git"
},
"author": "Ray Villalobos",
// create a command called serve dash dev and in here
"scripts":{
"serve-dev":"live-server builds/development",
"prod-setup":"mkdirp builds/production/js",
// using start is that when I run my command I don't need to add the word run.
"start":"npm run serve-dev",
// you can also run a script before one of these scripts with the special name.
"prestart": "npm run prod-setup"
},
"devDependencies": {
"live-server": "^1.2.0"
}
}

execute the command with npm run

npm run serve-dev

using start is that when I run my command I don’t need to add the word run.

1
npm start
打赏支持:如果你觉得我的文章对你有所帮助,可以打赏我哟。