Npm: Difference between revisions
Jump to navigation
Jump to search
Line 1: | Line 1: | ||
= Useful commands = | = Useful commands = | ||
List the packages at depth | List the packages at depth | ||
<syntaxhighlight lang="bash"> | |||
npm list --depth 0 | npm list --depth 0 | ||
</syntaxhighlight> | |||
= New Babel 7 Project = | = New Babel 7 Project = | ||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> |
Revision as of 19:29, 5 November 2019
Useful commands
List the packages at depth
npm list --depth 0
New Babel 7 Project
mkdir project1
mkdir project1/src
cd project1
npm init
npm install --save-dev @babel/core
npm install --save-dev @babel/cli
npm install --save-dev @babel/preset-env
Create in the root .babel.rc
{
"presets": ["@babel/preset-env"]
}
</html>
Create src/index.js
<source>
import express from "express";
const app = express();
app.use("/", (req, res) => {
res.status(200).send("Hello World");
});
app.listen(3000);
console.log("Server running at http://localhost:3000/");
export { app as default };
Make the package.json to look like this
{
"name": "rest-api3",
"version": "1.0.0",
"description": "",
"main": "src/index.js",
"scripts": {
"start": "nodemon src/index.js --exec babel-node"
},
"author": "",
"license": "ISC",
"devDependencies": {
"@babel/cli": "^7.6.4",
"@babel/core": "^7.6.4",
"@babel/preset-env": "^7.6.3"
},
"dependencies": {
"@babel/node": "^7.6.3",
"express": "^4.17.1",
"nodemon": "^1.19.4"
}
}