node.js - 当我在控制台中键入 $ npm build 时,bash 脚本没有运行
问题描述
我想写一个批处理脚本(build.sh
)来安装依赖,运行前端,同时运行后端
包.json 文件
"scripts": {
"dev": "nodemon server.js",
"client": "cd client && npm start",
"start": "concurrently \"npm run dev\" \"npm run client\" ",
"build": "chmod +x ./build.sh"
},
构建.sh 文件
#!/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
我不确定让它正常运行我缺少什么?提前致谢!
当我$ npm build
在命令行(当然是在应用程序的目录中)输入 , 时,我得到了这个:
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
npm@6.14.5 /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
npm@6.14.5 /usr/local/lib/node_modules/npm
Did you mean this?
rebuild
解决方案
build
不是有效的 CLI 命令npm
。要运行 中build
定义的脚本package.json
,请执行$ npm run build
.
推荐阅读
- java - Spring Webflux - 反应式 Cassandra - 配置 ConsistencyLevel
- c# - N 层应用程序中的异常处理
- asp.net-core - IWebHostBuilder.PreferHostingUrls 的目的是什么
- cmd - TYPO3 v10:在 Windows 10 上使用 cmd 安装扩展
- google-analytics-api - Google Analytics Data API (GA4) 中 ga:adContent 和 ga:keyword 的等效维度
- php - Laravel Spark 403 - 3D 安全支付时重定向主机不匹配
- python-3.x - qt5 库有什么问题?
- javascript - 在传单地图上显示 geotiff 栅格数据时出错
- c# - 将流读取到分隔符的最佳方法
- c++ - 通过 C++ 中的 unsigned char* 函数参数传递和接收原始字节数据