Reputation: 183
I want to write a batch script (build.sh
) to install dependencies, run front end, and run back end at the same time
package.json file
"scripts": {
"dev": "nodemon server.js",
"client": "cd client && npm start",
"start": "concurrently \"npm run dev\" \"npm run client\" ",
"build": "chmod +x ./build.sh"
},
build.sh file
#!/bin/bash
npm run build
npm i aws-sdk body-parser concurrently cors dotenv express joi mongoose multer multer-s3
cd client
npm i axios bootstrap config jquery node-modules react react-bootstrap react-dom react-scripts redux redux-form redux-thunk web-vitals
cd ..
npm start
I'm not sure what I'm missing to have it run properly? Thanks in advance!
When I type $ npm build
, into the command line (in the app's directory of course) I get this:
Usage: npm <command>
where <command> is one of:
access, adduser, audit, bin, bugs, c, cache, ci, cit,
clean-install, clean-install-test, completion, config,
create, ddp, dedupe, deprecate, dist-tag, docs, doctor,
edit, explore, fund, get, help, help-search, hook, i, init,
install, install-ci-test, install-test, it, link, list, ln,
login, logout, ls, org, outdated, owner, pack, ping, prefix,
profile, prune, publish, rb, rebuild, repo, restart, root,
run, run-script, s, se, search, set, shrinkwrap, star,
stars, start, stop, t, team, test, token, tst, un,
uninstall, unpublish, unstar, up, update, v, version, view,
whoami
npm <command> -h quick help on <command>
npm -l display full usage info
npm help <term> search for help on <term>
npm help npm involved overview
Specify configs in the ini-formatted file:
/Users/SebastianRusso/.npmrc
or on the command line via: npm <command> --key value
Config info can be viewed via: npm help config
[email protected] /usr/local/lib/node_modules/npm
Did you mean this?
rebuild
Sebastians-MacBook-Pro:profile-app-server SebastianRusso$ npm buildd
Usage: npm <command>
where <command> is one of:
access, adduser, audit, bin, bugs, c, cache, ci, cit,
clean-install, clean-install-test, completion, config,
create, ddp, dedupe, deprecate, dist-tag, docs, doctor,
edit, explore, fund, get, help, help-search, hook, i, init,
install, install-ci-test, install-test, it, link, list, ln,
login, logout, ls, org, outdated, owner, pack, ping, prefix,
profile, prune, publish, rb, rebuild, repo, restart, root,
run, run-script, s, se, search, set, shrinkwrap, star,
stars, start, stop, t, team, test, token, tst, un,
uninstall, unpublish, unstar, up, update, v, version, view,
whoami
npm <command> -h quick help on <command>
npm -l display full usage info
npm help <term> search for help on <term>
npm help npm involved overview
Specify configs in the ini-formatted file:
/Users/SebastianRusso/.npmrc
or on the command line via: npm <command> --key value
Config info can be viewed via: npm help config
[email protected] /usr/local/lib/node_modules/npm
Did you mean this?
rebuild
Upvotes: 1
Views: 1298
Reputation: 363
"build": "chmod +x ./build.sh"
should be:
"build": "./build.sh"
chmod +x
just makes the build.sh
file executable, it doesn't actually run it.
Then to run the build command from npm you have to use npm run build
like the other answer said.
Upvotes: 0
Reputation: 142
build
is not a valid CLI command for npm
. To run the build
script defined in the package.json
, do $ npm run build
.
Upvotes: 1