npm ERR!缺少脚本:构建;

时间:2020-08-18 08:32:36

标签: javascript node.js typescript

enter image description here

npm ERR!缺少脚本:构建;我发现这很奇怪,是什么原因引起的?

有什么想法吗?我添加了包括package.json在内的全栈错误。请同时检查下面的build.sh代码

全栈错误

> eslint --quiet ./simple/js/*.js

npm ERR! missing script: build;
npm ERR!
npm ERR! Did you mean this?
npm ERR!     build

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\jgulle\AppData\Roaming\npm-cache\_logs\2020-08-18T08_34_05_215Z-debug.log
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! encrypt-decrypt-demo@1.0.3 start: `npm run lint && (npm run build; cd server; npm install; node 
server.js)`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the encrypt-decrypt-demo@1.0.3 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.       

npm ERR! A complete log of this run can be found in:

Package.json

{
  "name": "encrypt-decrypt-demo",
  "version": "1.0.3",
  "description": "Simple example to encrypt and decrypt files in the TDF spec using Virtru hosted KAS and EAS.",
  "scripts": {
    "build": ".simple/scripts/build.sh",
    "lint": "eslint --quiet ./simple/js/*.js",
    "start": "npm run lint && (npm run build; cd server; npm install; node server.js)",
    "watch": "nodemon --watch ./simple/js --ignore ./simple/js/build --exec 'npm run start'",
    "audit": "audit-ci --config .audit-ci.json"
  },
  "dependencies": {
    "browserify": "16.2.3",
    "moment": "2.24.0"
  },
  "devDependencies": {
    "audit-ci": "^2.3.0",
    "eslint": "^6.2.1",
    "eslint-config-airbnb-base": "^14.0.0",
    "eslint-plugin-import": "^2.18.2",
    "nodemon": "^1.19.1",
    "webpack-cli": "^3.3.6"
  }
}

build.sh代码

cleanup(){
    if [ -f ./simple/js/build/demo-utils.js ]; then 
        rm ./simple/js/build/demo-utils.js; 
    fi
}

build(){
    browserify ./simple/js/browserify.js -o ./simple/js/build/demo-utils.js
}

cleanup && build

1 个答案:

答案 0 :(得分:2)

"start": "npm run lint && npm run build && cd server && npm install && node server.js

它正试图找到一个名为“ build;”的脚本。使用半冒号,因此请将其更改为&&,并加上空格

和构建脚本将其更改为:

"build": " bash simple/scripts/build.sh"