npm为bootstrap4 UI Framework Web项目运行构建错误

时间:2017-10-19 17:39:35

标签: deployment npm build npm-scripts

我需要一些帮助。

在我向Windows 10的终端输入npm run build后,我收到以下错误:

  

'imagemin'未被识别为内部或外部命令,   可操作程序或批处理文件。错误的ERR!代码ELIFECYCLE npm ERR!   错误1 npm ERR! confusion@1.0.0 imagemin:imagemin img/* -o dist/img npm ERR!退出状态1 npm ERR!错误的ERR!失败了   confusion@1.0.0 imagemin脚本。错误的ERR!这可能不是一个   npm的问题。上面可能有额外的日志记录输出。 NPM   呃!可以在以下位置找到此运行的完整日志:npm ERR!
  C:\ Users \用户ndunga \应用程序数据\漫游\ NPM-cache_logs \ 2017-10-19T16_46_04_328Z-的debug.log   错误的ERR!代码ELIFECYCLE npm ERR!错误1 npm ERR! confusion@1.0.0   构建:npm run clean && npm run copyfonts && npm run imagemin && npm run usemin npm ERR!退出状态1 npm ERR!错误的ERR!失败了   confusion@1.0.0构建脚本。错误的ERR!这可能不是问题   与npm。上面可能有额外的日志记录输出。错误的ERR!一个   可以在以下位置找到此运行的完整日志:npm ERR!
  C:\ Users \用户ndunga \应用程序数据\漫游\ NPM-cache_logs \ 2017-10-19T16_46_04_381Z-的debug.log

这是我的package.json文件

{
  "name": "confusion",
  "version": "1.0.0",
  "description": "This is a website for Ristorante Con Fusion",
  "main": "index.html",
  "scripts": {
    "start": "npm run watch:all",
    "test": "echo \"Error: no test specified\" && exit 1",
    "lite": "lite-server",
    "scss": "node-sass -o css/ css/",
    "watch:scss": "onchange \"css/*.scss\" -- npm run scss",
    "watch:all": "parallelshell \"npm run watch:scss\" \"npm run lite\"",
    "clean": "rimraf dist",
    "copyfonts": "copyfiles -f node_modules/font-awesome/fonts/* dist/fonts",
    "imagemin": "imagemin img/* -o dist/img",
    "usemin": "usemin contactus.html -d dist --htmlmin -o dist/contactus.html && usemin aboutus.html -d dist --htmlmin -o dist/aboutus.html && usemin index.html -d dist --htmlmin -o dist/index.html",
    "build": "npm run clean && npm run copyfonts && npm run imagemin && npm run usemin"
  },
  "author": "",
  "license": "ISC",
  "devDependencies": {
    "cssmin": "^0.4.3",
    "htmlmin": "0.0.7",
    "lite-server": "^2.2.2",
    "node-sass": "^4.5.3",
    "onchange": "^3.2.1",
    "parallelshell": "^3.0.2",
    "rimraf": "^2.6.2",
    "uglifyjs": "^2.4.11",
    "usemin-cli": "^0.5.1"
  },
  "dependencies": {
    "bootstrap": "^4.0.0-alpha.6",
    "font-awesome": "^4.7.0"
  }
}

3 个答案:

答案 0 :(得分:0)

您没有安装imagemin软件包。

npm install imagemin --save

答案 1 :(得分:0)

安装imagemin-cli并像在"imagemin": "imagemin img/ --out-dir=dist/img"中的package.json一样使用它

答案 2 :(得分:0)

这对我有效(Windows 10):

打开index.js文件(路径:\ Bootstrap4 \ conFusion \ node_modules \ parallelshell \ index.js) 在第105行,而不是“ cwd:process.versions.node”,更改为“ cwd:parseInt(process.versions.node)”