I am creating a dependancy to generate PDF on nestjs, to do it I am using puppeteer.
When I try to use puppeteer inside the dependancy I get an error:
Error: Run `npm install` to download the correct Chromium revision (1056772).
But when I do it from the project and not the dependancy there is no error. It only happen when I use puppeteer from the dependancy, but it's launched from the same project.
First I generated the PDF inside a nestjs project and it worked fine.
Then I moved the code to my library inside a service but then there is the error.
I tried to run the following command to install chromium
node node_modules/puppeteer/install.js
But nothing change and here is the result of the command:
Chromium is already in C:\Users\Greg.cache\puppeteer\chrome\win64-1069273; skipping download.
I also tried to delete the node modules and reinstall it but no change.
The package.json of the dependancy:
{
"name": "#gboutte/nestjs-pdf",
"version": "0.0.3",
"description": "This package provide a service to render PDF from html string or from handlebars tempaltes for nestjs.",
"keywords": [
"nestjs",
"handlebars",
"hbs",
"templates",
"pdf"
],
"homepage": "https://github.com/gboutte/nestjs-pdf#readme",
"bugs": {
"url": "https://github.com/gboutte/nestjs-pdf/issues",
"email": "gboutte#protonmail.com"
},
"repository": {
"type": "git",
"url": "https://github.com/gboutte/nestjs-pdf"
},
"main": "dist/index.js",
"types": "dist/index.d.ts",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"build": "rimraf dist && tsc",
"prepublish": "npm run build"
},
"author": "Grégory Boutte <gboutte#protonmail.com>",
"license": "MIT",
"dependencies": {},
"devDependencies": {
"#nestjs/common": "^9.1.6",
"#gboutte/nestjs-hbs": "^0.0.3",
"#types/node": "^18.11.5",
"puppeteer": "^19.1.2",
"reflect-metadata": "^0.1.13",
"rimraf": "^3.0.2",
"rxjs": "^7.5.7",
"typescript": "^4.8.4"
},
"peerDependencies": {
"#nestjs/common": "^9.1.6",
"#gboutte/nestjs-hbs": "^0.0.3",
"#types/node": "^18.11.5",
"puppeteer": "^19.1.2",
"reflect-metadata": "^0.1.13",
"rimraf": "^3.0.2",
"rxjs": "^7.5.7",
"typescript": "^4.8.4"
}
}
And the package.json of the main project
{
"name": "nestjs-hbs-demo",
"version": "0.0.1",
"description": "",
"author": "",
"private": true,
"main": "dist/index.js",
"readmeFilename": "README.md",
"files": [
"dist/**/*",
"*.md"
],
"license": "UNLICENSED",
"scripts": {
"prebuild": "rimraf dist",
"build": "nest build",
"format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"",
"start": "nest start",
"start:dev": "nest start --watch",
"start:debug": "nest start --debug --watch",
"start:prod": "node dist/main",
"lint": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix",
"test": "jest",
"test:watch": "jest --watch",
"test:cov": "jest --coverage",
"test:debug": "node --inspect-brk -r tsconfig-paths/register -r ts-node/register node_modules/.bin/jest --runInBand",
"test:e2e": "jest --config ./test/jest-e2e.json"
},
"dependencies": {
"#gboutte/nestjs-hbs": "file:../nestjs-hbs",
"#gboutte/nestjs-pdf": "file:../nestjs-pdf",
"#nestjs/common": "^9.0.0",
"#nestjs/core": "^9.0.0",
"#nestjs/platform-express": "^9.0.0",
"#nestjs/platform-fastify": "^9.1.6",
"puppeteer": "^19.4.1",
"reflect-metadata": "^0.1.13",
"rimraf": "^3.0.2",
"rxjs": "^7.2.0"
},
"devDependencies": {
"#nestjs/cli": "^9.0.0",
"#nestjs/schematics": "^9.0.0",
"#nestjs/testing": "^9.0.0",
"#types/express": "^4.17.13",
"#types/jest": "28.1.8",
"#types/node": "^16.0.0",
"#types/supertest": "^2.0.11",
"#typescript-eslint/eslint-plugin": "^5.0.0",
"#typescript-eslint/parser": "^5.0.0",
"eslint": "^8.0.1",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-prettier": "^4.0.0",
"jest": "28.1.3",
"prettier": "^2.3.2",
"source-map-support": "^0.5.20",
"supertest": "^6.1.3",
"ts-jest": "28.0.8",
"ts-loader": "^9.2.3",
"ts-node": "^10.0.0",
"tsconfig-paths": "4.1.0",
"typescript": "^4.7.4"
},
"jest": {
"moduleFileExtensions": [
"js",
"json",
"ts"
],
"rootDir": "src",
"testRegex": ".*\\.spec\\.ts$",
"transform": {
"^.+\\.(t|j)s$": "ts-jest"
},
"collectCoverageFrom": [
"**/*.(t|j)s"
],
"coverageDirectory": "../coverage",
"testEnvironment": "node"
}
}
I resolved the issue by updating my local nodejs and I changed the #types/node dependency of both project to be the same.
"#types/node": "^18.0.0",
I found out that it was this problem by trying to install the library with github instead of locally.
Before I used npm install ../directory-to-my-lib, then I used npm install <url to the github repo>.
The difference is that using github npm gave me an error saying that both version of #types/node were different, I don't know why I did not have this error using the other command.
Now that I fixed the version it works with all installation methods (npm package / github / locally).
Related
I have the following code in main.ts file
async function bootstrap() {
const app = await NestFactory.create<NestExpressApplication>(AppModule);
console.log("working");
await app.listen(3000);
}
bootstrap();
when I run my application it runs successfully, but I am unable to access my controller's endpoints. I do not even see the working from console logs on my screen. It was running fine, but then stopped working after a while. I believe it could be due to some library I have added.
Just in case if it matters, below is my package.json
{
"name": "sfsf",
"version": "0.0.1",
"description": "",
"author": "",
"private": true,
"license": "UNLICENSED",
"scripts": {
"prebuild": "rimraf dist",
"build": "nest build",
"format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"",
"start": "npm run start:dev",
"start:dev": "nest start --watch",
"start:debug": "nest start --debug --watch",
"start:prod": "node dist/main",
"lint": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix",
"test": "jest",
"test:watch": "jest --watch",
"test:cov": "jest --coverage",
"test:debug": "node --inspect-brk -r tsconfig-paths/register -r ts-node/register node_modules/.bin/jest --runInBand",
"test:e2e": "jest --config ./test/jest-e2e.json",
"typeorm": "ts-node-dev ./node_modules/typeorm/cli.js"
},
"dependencies": {
"#nestjs/common": "^7.0.0",
"#nestjs/core": "^7.0.0",
"#nestjs/jwt": "^8.0.0",
"#nestjs/passport": "^8.0.1",
"#nestjs/platform-express": "^7.0.0",
"#nestjs/typeorm": "^8.0.2",
"bcryptjs": "^2.4.3",
"class-validator": "^0.13.2",
"dotenv": "^10.0.0",
"module": "^1.2.5",
"mysql2": "^2.3.3",
"passport": "^0.4.1",
"passport-jwt": "^4.0.0",
"passport-local": "^1.0.0",
"reflect-metadata": "^0.1.13",
"rimraf": "^3.0.2",
"rxjs": "^7.4.0",
"typeorm": "^0.2.41"
},
"devDependencies": {
"#nestjs/cli": "^7.0.0",
"#nestjs/schematics": "^7.0.0",
"#nestjs/testing": "^7.0.0",
"#types/express": "^4.17.3",
"#types/jest": "26.0.10",
"#types/node": "^13.9.1",
"#types/passport-jwt": "^3.0.6",
"#types/passport-local": "^1.0.34",
"#types/supertest": "^2.0.8",
"#typescript-eslint/eslint-plugin": "3.9.1",
"#typescript-eslint/parser": "3.9.1",
"eslint": "7.7.0",
"eslint-config-prettier": "^6.10.0",
"eslint-plugin-import": "^2.20.1",
"jest": "26.4.2",
"prettier": "^1.19.1",
"supertest": "^4.0.2",
"ts-jest": "26.2.0",
"ts-loader": "^6.2.1",
"ts-node": "9.0.0",
"tsconfig-paths": "^3.9.0",
"typescript": "^3.7.4"
},
"jest": {
"moduleFileExtensions": [
"js",
"json",
"ts"
],
"rootDir": "src",
"testRegex": ".spec.ts$",
"transform": {
"^.+\\.(t|j)s$": "ts-jest"
},
"coverageDirectory": "../coverage",
"testEnvironment": "node"
}
}
Upgrade every #nestjs/* package to v8. Or downgrade them to v7 and rxjs to v6
I currently have a directory myproject/
In myproject I have these
/src
/public
package.json
etc.
Normal stuff you'd see in a react app.
I pushed this to a server aws lightsail nodejs
I then run npm install.
After I do all this I go and run npm run build
I get this output:
> react-scripts build
Creating an optimized production build...
Failed to compile.
./src/index.js
Cannot find module: 'layouts/Admin.jsx'. Make sure this package is installed.
You can install this package by running: npm install layouts/Admin.jsx.
The files it's calling for are in the directory.
Here is package.json
{
"name": "argon-dashboard-react",
"version": "1.0.0",
"description": "React version of Argon Dashboard by Creative Tim",
"main": "index.js",
"repository": {
"type": "git",
"url": "git+https://github.com/creativetimofficial/argon-dashboard-react.git"
},
"keywords": [
"react",
"reactjs",
"argon",
"argon-react",
"dashboard",
"dashboard-react",
"argon-dashboard",
"argon-dashboard-react"
],
"author": "Creative Tim",
"license": "MIT",
"bugs": {
"url": "https://github.com/creativetimofficial/argon-dashboard-react/issues"
},
"homepage": "https://demos.creative-tim.com/argon-dashboard-react/",
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject",
"install:clean": "rm -rf node_modules/ && rm -rf package-lock.json && npm install && npm start",
"compile-sass": "node-sass src/assets/scss/argon-dashboard-react.scss src/assets/css/argon-dashboard-react.css",
"minify-sass": "node-sass src/assets/scss/argon-dashboard-react.scss src/assets/css/argon-dashboard-react.min.css --output-style compressed",
"map-sass": "node-sass src/assets/scss/argon-dashboard-react.scss src/assets/css/argon-dashboard-react.css --source-map true"
},
"eslintConfig": {
"extends": "react-app"
},
"browserslist": [
">0.2%",
"not dead",
"not ie <= 11",
"not op_mini all"
],
"dependencies": {
"#material-ui/core": "^4.6.1",
"#material-ui/icons": "^4.5.1",
"chart.js": "2.7.3",
"classnames": "2.2.6",
"firebase": "^6.6.2",
"firebase-admin": "^8.8.0",
"http2": "^3.3.7",
"moment": "2.24.0",
"node-sass": "4.11.0",
"nouislider": "13.1.1",
"react": "16.9.0",
"react-bootstrap-table-next": "^3.2.1",
"react-chartjs-2": "2.7.4",
"react-copy-to-clipboard": "5.0.1",
"react-data-table-component": "4.0.1",
"react-datepicker": "^2.9.6",
"react-datetime": "2.16.3",
"react-dom": "16.9.0",
"react-google-maps": "9.4.5",
"react-loading-screen": "0.0.17",
"react-router-dom": "4.3.1",
"react-scripts": "2.1.8",
"reactstrap": "7.1.0",
"recompose": "^0.30.0",
"styled-components": "^4.4.1",
"sweetalert2": "^9.5.4",
"sweetalert2-react-content": "^2.0.2"
},
"devDependencies": {
"#types/googlemaps": "3.30.18",
"#types/markerclustererplus": "2.1.33",
"#types/react": "16.8.7",
"typescript": "3.3.3333"
}
}
Any idea what's going on with this?
The problem was related to the way I was using my import paths for components.
In example, currently I have:
import UserHeader from "components/Headers/UserHeader.jsx";
The correct way to have set them was:
import UserHeader from "../../components/Headers/UserHeader.jsx";
What was throwing me off was that locally it worked.
Been struggling for a couple days to run the project in prod and it just keeps showing different errors. The last one(hopefully) is:
> rimraf dist && tsc -p tsconfig.build.json
tsc-watch/test/fixtures/failing.ts(2,1): error TS1005: '}' expected.
But tsconfig.build.json is fine:
{
"extends": "./tsconfig.json",
"exclude": ["node_modules", "dist", "test", "**/*spec.ts"]
}
It happens after I try to build/run the docker container with:
docker-compose up --force-recreate --build
Here's what I have in the Dockerfile:
FROM node:11-stretch
ADD ./* $HOME/
RUN npm install
RUN npm run build
CMD npm run start:prod
And the package.json
{
"name": "mvp-api",
"private": true,
"version": "0.0.1",
"description": "MVP API",
"license": "MIT",
"scripts": {
"build": "rimraf dist && tsc -p tsconfig.build.json",
"format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"",
"start": "ts-node -r tsconfig-paths/register src/main.ts",
"start:dev": "tsc-watch -p tsconfig.build.json --onSuccess \"node dist/main.js\"",
"start:debug": "tsc-watch -p tsconfig.build.json --onSuccess \"node --inspect-brk dist/main.js\"",
"start:prod": "node dist/main.js",
"lint": "tslint -p tsconfig.json -c tslint.json",
"test": "jest",
"test:watch": "jest --watch",
"test:cov": "jest --coverage",
"test:debug": "node --inspect-brk -r tsconfig-paths/register -r ts-node/register node_modules/.bin/jest --runInBand",
"test:e2e": "jest --config ./test/jest-e2e.json"
},
"dependencies": {
"#nestjs/common": "^6.5.3",
"#nestjs/core": "^6.5.3",
"#nestjs/jwt": "^6.1.1",
"#nestjs/microservices": "^6.0.4",
"#nestjs/passport": "^6.1.0",
"#nestjs/platform-express": "^6.0.4",
"#nestjs/swagger": "^3.1.0",
"#nestjs/typeorm": "^6.1.3",
"#nestjs/websockets": "^6.0.4",
"#nestrx/twilio": "0.0.2",
"#types/mailgun-js": "^0.22.3",
"#types/qrcode": "^1.3.4",
"aws-sdk": "^2.513.0",
"cache-manager": "^2.10.0",
"cache-manager-mongodb": "^0.2.1",
"cache-manager-redis-store": "^1.5.0",
"class-transformer": "^0.2.3",
"class-validator": "^0.10.0",
"dotenv": "^8.0.0",
"hbs": "^4.0.4",
"is-base64": "^0.1.0",
"libphonenumber-js": "^1.7.22",
"mailgun-js": "^0.22.0",
"mysql": "^2.17.1",
"nestjs-config": "^1.4.3",
"onesignal-node": "^2.1.1",
"passport": "^0.4.0",
"passport-jwt": "^4.0.0",
"qrcode": "^1.4.1",
"randomstring": "^1.1.5",
"reflect-metadata": "0.1.13",
"rimraf": "2.6.3",
"rxjs": "6.4.0",
"swagger-ui-express": "^4.0.7",
"twilio": "^3.33.4",
"typeorm": "^0.2.18",
"vcard-generator": "0.0.7"
},
"devDependencies": {
"#nestjs/testing": "6.1.1",
"#types/cache-manager": "^2.10.0",
"#types/express": "4.16.1",
"#types/jest": "24.0.11",
"#types/node": "11.13.4",
"#types/randomstring": "^1.1.6",
"#types/supertest": "2.0.7",
"jest": "24.7.1",
"prettier": "1.17.0",
"supertest": "4.0.2",
"ts-jest": "24.0.2",
"ts-loader": "^6.0.4",
"ts-node": "8.1.0",
"tsc-watch": "2.2.1",
"tsconfig-paths": "3.8.0",
"tslint": "5.16.0",
"typescript": "3.4.3",
"webpack": "^4.39.2",
"webpack-cli": "^3.3.6",
"webpack-node-externals": "^1.7.2"
},
"jest": {
"moduleFileExtensions": [
"js",
"json",
"ts"
],
"rootDir": "src",
"testRegex": ".spec.ts$",
"transform": {
"^.+\\.(t|j)s$": "ts-jest"
},
"collectCoverageFrom": [
"**/*.(t|j)s"
],
"coverageDirectory": "../coverage",
"testEnvironment": "node"
}
}
It used to build fine with these configurations but after purging all containers/images and trying to recreate everything it just doesn't work.
Does anyone know how to get it to run properly in prod?
Apparently the problem was that the node_modules would keep copying over.
Adding a .dockerignore file with the following content solves the problem:
node_modules
Now I can run the docker container successfully.
I have followed the tutorial for nestJs and have a basic working app. After that, I tried the tutorial to connect my app with webpack and hotreloading and am now presented with the following error:
import { Entity, Column, PrimaryGeneratedColumn } from 'typeorm';
SyntaxError: Unexpected token {
at Module._compile (internal/modules/cjs/loader.js:703:23)
I have tried looking at similar errors and cannot find anything conclusive other than hints here and there to something that is not compiling in my test files - any direction would be greatly appreciated.
Using Node 12, npm 6.9.0
Package JSON below:
"scripts": {
"build": "tsc -p tsconfig.build.json",
"format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"",
"start": "node dist/server",
"webpack": "webpack --config webpack.config.js",
"start:dev": "concurrently --handle-input \"wait-on dist/main.js && nodemon\" \"tsc -w -p tsconfig.build.json\" ",
"start:debug": "nodemon --config nodemon-debug.json",
"prestart:prod": "rimraf dist && npm run build",
"start:prod": "node dist/main.js",
"lint": "tslint -p tsconfig.json -c tslint.json",
"test": "jest",
"test:watch": "jest --watch",
"test:cov": "jest --coverage",
"test:debug": "node --inspect-brk -r tsconfig-paths/register -r ts-node/register node_modules/.bin/jest --runInBand",
"test:e2e": "jest --config ./test/jest-e2e.json"
},
"dependencies": {
"#nestjs/common": "^6.0.4",
"#nestjs/core": "^6.0.4",
"#nestjs/microservices": "^6.0.4",
"#nestjs/platform-express": "^6.0.4",
"#nestjs/swagger": "^3.0.2",
"#nestjs/typeorm": "^6.1.1",
"#nestjs/websockets": "^6.0.4",
"mysql": "^2.17.1",
"reflect-metadata": "0.1.13",
"rimraf": "2.6.3",
"rxjs": "6.4.0",
"swagger-ui-express": "^4.0.4",
"typeorm": "^0.2.17"
},
"devDependencies": {
"#nestjs/testing": "6.1.1",
"#types/express": "^4.16.1",
"#types/jest": "24.0.11",
"#types/node": "11.13.4",
"#types/supertest": "2.0.7",
"concurrently": "^4.1.0",
"jest": "24.7.1",
"nodemon": "1.18.11",
"prettier": "1.17.0",
"supertest": "4.0.2",
"ts-jest": "24.0.2",
"ts-loader": "^6.0.1",
"ts-node": "8.1.0",
"tsconfig-paths": "3.8.0",
"tslint": "5.16.0",
"typescript": "3.4.3",
"wait-on": "^3.2.0",
"webpack": "^4.32.2",
"webpack-cli": "^3.3.2",
"webpack-node-externals": "^1.7.2"
},
"jest": {
"moduleFileExtensions": [
"js",
"json",
"ts"
],
"rootDir": "src",
"testRegex": ".spec.ts$",
"transform": {
"^.+\\.(t|j)s$": "ts-jest"
},
"collectCoverageFrom": [
"**/*.(t|j)s"
],
"coverageDirectory": "../coverage",
"testEnvironment": "node"
}
this is probably the tsconfig, are you using:
"module": "commonjs" In the compilerOptions ? When you working with nodejs this is the option that you have to use
I finally posted this on NestJS repo and received a response for those interested:
https://github.com/nestjs/nest/issues/2389
I'm a newbie nodejs. I have a trouble about deploying nodejs app to google app engine. This is my error, I have been trying to fix it but it's not work. I've installed babel.
Bug
Updating service [default]...failed.
ERROR: (gcloud.app.deploy) Error Response: [9]
Application startup error:
restaurant_api#1.0.0 prestart /app
npm run -s build
You have mistakenly installed the babel package, which is a no-op in Babel 6.
Babel's CLI commands have been moved from the babel package to the babel-cli package.
npm uninstall babel
npm install --save-dev babel-cli
This is my package.json
"main": "dist",
"scripts": {
"dev": "NODE_ENV=development nodemon -w src --exec \"babel-node src --presets es2015,stage-0\"",
"build": "babel src -s -D -d dist --presets es2015,stage-0",
"start": "NODE_ENV=production pm2 start dist",
"prestart": "npm run -s build",
"lint": "eslint src",
"test": "echo \"Error: no test specified\" && exit 1",
"babel-version": "babel --version"
},
"eslintConfig": {
"parserOptions": {
"ecmaVersion": 7,
"sourceType": "module"
},
"env": {
"node": true
},
"rules": {
"no-console": 0,
"no-unused-vars": 1
}
},
"author": "",
"license": "ISC",
"dependencies": {
"babel": "^6.23.0",
"body-parser": "^1.17.0",
"express": "^4.15.0",
"express-jwt": "^5.1.0",
"jsonwebtoken": "^7.3.0",
"mongoose": "^4.8.5",
"passport": "^0.3.2",
"passport-local": "^1.0.0",
"passport-local-mongoose": "^4.0.0",
"pm2": "^2.4.2"
},
"devDependencies": {
"babel-cli": "^6.23.0",
"babel-eslint": "^7.1.1",
"babel-preset-es2015": "^6.22.0",
"babel-preset-stage-0": "^6.22.0",
"eslint": "^3.16.1"
}
Problem is quite simple, if you notice clearly GAE, does not install dev-dependencies. So move your dev-deps above inside deps , like I did and babel no found error is gone.
{
"name": "scraping",
"version": "0.3.0",
"description": "Starter project for an ES6 RESTful Express API",
"main": "dist",
"scripts": {
"dev": "nodemon -w src --exec \"babel-node src --presets es2015,stage-0\"",
"build": "babel src -s -D -d dist --presets es2015,stage-0",
"start": "node dist",
"prestart": "npm run -s build",
"test": "eslint src"
},
"eslintConfig": {
"extends": "eslint:recommended",
"parserOptions": {
"ecmaVersion": 7,
"sourceType": "module"
},
"env": {
"node": true
},
"rules": {
"no-console": 0,
"no-unused-vars": 1
}
},
"repository": {
"type": "git",
"url": "git+https://github.com/developit/express-es6-rest-api.git"
},
"author": "Saransh Sharma <jason#developit.ca>",
"license": "MIT",
"dependencies": {
"body-parser": "^1.13.3",
"compression": "^1.5.2",
"cors": "^2.7.1",
"express": "^4.13.3",
"morgan": "^1.8.0",
"resource-router-middleware": "^0.6.0",
"#jonstuebe/scraper": "^0.1.4",
"babel-cli": "^6.9.0",
"babel-core": "^6.9.0",
"babel-preset-es2015": "^6.9.0",
"babel-preset-stage-0": "^6.5.0",
"eslint": "^3.1.1",
"nodemon": "^1.9.2"
},
"devDependencies": {
"babel-cli": "^6.9.0",
"babel-core": "^6.9.0",
"babel-preset-es2015": "^6.9.0",
"babel-preset-stage-0": "^6.5.0",
"eslint": "^3.1.1",
"nodemon": "^1.9.2"
},
"bugs": {
"url": "https://github.com/developit/express-es6-rest-api/issues"
},
"homepage": "https://github.com/developit/express-es6-rest-api#readme",
"keywords": [
"scraper",
"product",
"from",
"amazon"
]
}
The clue is in the error message.
In your devDependencies section, you already have babel-cli included.
However, your dependencies section still has a reference to "babel": "^6.23.0".
Either remove this line, or replace it with babel-cli, leaving you with:
"dependencies": {
"babel-cli": "^6.23.0",
"body-parser": "^1.17.0",
"express": "^4.15.0",
"express-jwt": "^5.1.0",
"jsonwebtoken": "^7.3.0",
"mongoose": "^4.8.5",
"passport": "^0.3.2",
"passport-local": "^1.0.0",
"passport-local-mongoose": "^4.0.0",
"pm2": "^2.4.2"
},
You need to install babel-cli globally, i.e. run the command "npm install babel-cli -g" as part of your build npm script, or create a pre-install script that install it if you want to keep it more organized in case you need to add more things later on.
"scripts": {
"dev": "NODE_ENV=development nodemon -w src --exec \"babel-node src --presets es2015,stage-0\"",
"build": "npm install bable-cli -g && babel src -s -D -d dist --presets es2015,stage-0",