gpt4 book ai didi

node.js - 运行 npm build 时出现以下错误

转载 作者:太空宇宙 更新时间:2023-11-04 01:42:21 27 4
gpt4 key购买 nike

{
"name": "confusion",
"version": "1.0.0",
"main": "index.js",
"dependencies": {
"bootstrap-social": "^5.1.1",
"font-awesome": "^4.7.0",
"jquery": "^3.3.1",
"lite-server": "^2.4.0",
"popper.js": "^1.12.9"
},
"devDependencies": {
"cssmin": "^0.4.3",
"htmlmin": "0.0.7",
"node-sass": "^4.7.2",
"onchange": "^3.3.0",
"parallelshell": "^3.0.2",
"rimraf": "^2.6.2",
"uglifyjs": "^2.4.11",
"usemin-cli": "^0.5.1"
},
"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 imagemin && npm run copyfonts && npm run usemin"
}
}

C:\Users\username\Documents\coursera\Bootstrap4\conFusion>npm run build

> confusion@1.0.0 build C:\Users\username\Documents\coursera\Bootstrap4\conFusion
> npm run clean && npm run imagemin && npm run copyfonts && npm run usemin

> confusion@1.0.0 clean C:\Users\username\Documents\coursera\Bootstrap4\conFusion
> rimraf dist

> confusion@1.0.0 imagemin C:\Users\username\Documents\coursera\Bootstrap4\conFusion
> imagemin img/* -o dist/img

4 images minified

> confusion@1.0.0 copyfonts C:\Users\username\Documents\coursera\Bootstrap4\conFusion
> copyfiles -f node_modules/font-awesome/fonts/* dist/fonts

> confusion@1.0.0 usemin C:\Users\username\Documents\coursera\Bootstrap4\conFusion
> 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

undefined:1625
throw new JS_Parse_Error(message, filename, line, col, pos);
^
SyntaxError: Unexpected token: punc ({)
at JS_Parse_Error.get (eval at <anonymous> (C:\Users\username\Documents\coursera\Bootstrap4\conFusion\node_modules\usemin\node_modules\uglify-js\tools\node.js:27:1), <anonymous>:86:23)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! confusion@1.0.0 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`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the confusion@1.0.0 usemin 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:
npm ERR! C:\Users\username\AppData\Roaming\npm-cache\_logs\2018-09-24T21_38_01_183Z-debug.log
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! confusion@1.0.0 build: `npm run clean && npm run imagemin && npm run copyfonts && npm run usemin`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the confusion@1.0.0 build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

最佳答案

我正在做同样的类(class)并且犯了同样的错误。然而,我只是能够修复它。我通过重新安装所有开发依赖项并使用当前版本(而不是类(class)中的版本)来做到这一点。我也将 usemin 命令(根据此处的帖子)更改为

"imagemin": "imagemin img/* --out-dir=dist/img",

但是,它仍然不起作用,所以我使用以下工具检查了所有文件是否有错误:

https://www.freeformatter.com/java-regex-tester.html用于测试 html 文件; http://www.webtoolkitonline.com/javascript-tester.html ,用于测试 .js 文件和 https://jsonlint.com/?json= ,测试 package.json 文件是否有错误。

在我更正所有文件后,命令“npm run build”终于起作用了。 (我特别忘记检查 script.js 文件,我刚刚从仍然包含脚本标签的 html 文件中复制了代码)

关于node.js - 运行 npm build 时出现以下错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52487918/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com