【问题标题】:How to correct this error? usemin not found如何纠正这个错误?未找到用户名
【发布时间】:2020-05-17 17:29:23
【问题描述】:

我在安装 rimraf、copyfiles、imagemin、usemin-cli、cssmin、uglifyjs 和 htmlmin 后尝试运行 npm run build。然后编辑 package.json 文件。 但我得到了错误

sh: 1: usemin: 未找到

这是我的 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": "npx node-sass -o css/ css/",
    "watch:scss": "npx onchange 'css/*.scss' -- npm run scss",
    "watch:all": "concurrently 'npm run watch:scss' 'npm run lite'",
    "clean": "node_modules/rimraf/bin.js dist",
    "copyfonts": "copyfiles -f node_modules/font-awesome/fonts/* dist/fonts",
    "imagemin": "imagemin img/* --out-dir='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.3.0",
    "node-sass": "^4.7.2",
    "onchange": "^3.3.0",
    "parallelshell": "^3.0.1",
    "rimraf": "^2.6.2",
    "uglifyjs": "^2.4.11",
    "usemin-cli": "^0.5.1"
  },
  "dependencies": {
    "bootstrap": "^4.4.1",
    "bootstrap-social": "^5.1.1",
    "font-awesome": "^4.7.0",
    "jquery": "^3.4.1",
    "popper.js": "^1.12.9"
  }
}

尝试了谷歌,但没有找到任何东西。我正在使用 ubuntu

【问题讨论】:

  • 尝试运行npm install,它将添加你的 package.json 文件中的所有包。看起来你还没有安装 usemin 这与你已经安装的 usemin-cli 不同
  • 试过了,没用。
  • 哦,我看错了,我以为我看到useminusemin-cli 的一个单独的包。棘手的一个,您是否尝试过将脚本从 usemin 重命名为其他名称,这可能是与包名冲突的问题?
  • 是的,我试过了。

标签: node.js web-deployment web-development-server web-frontend npm-scripts


【解决方案1】:

我认为 npm 无法读取路径。

我添加了路径

node_modules/.bin/usemin

代替上面脚本中的usemin。

成功了。

【讨论】:

    【解决方案2】:

    这是usemin-cli版本的问题,升级到0.6.0版,我正在做同样的课程,它可以工作

    【讨论】:

      猜你喜欢
      • 2010-10-18
      • 2016-06-23
      • 2016-07-26
      • 1970-01-01
      • 2021-09-11
      • 2012-03-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多