{
"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.
答案 0 :(得分:0)
您可能正在使用ES6语法,但使用的是ES5预设。
添加babel-preset-es2015
依赖关系以解决此问题。
还要在.babelrc文件中添加'es2015'
。
json
{
"presets": ["es2015"]
}
答案 1 :(得分:0)
按照imagemin的GitHub页面,它有解决方案: https://github.com/imagemin/imagemin-cli
替换
"imagemin": "imagemin img/* -o dist/img",
与
"imagemin": "imagemin img/* --out-dir=dist/img",
答案 2 :(得分:0)
我正在执行相同的课程,并且遇到相同的错误。但是,我只是能够解决它。我通过重新安装所有开发依赖项并使用当前版本(而不是本课程中的版本)来完成此操作。 我也确实将usemin命令(根据此处的帖子)更改为
“ imagemin”:“ imagemin img / * --out-dir = dist / img”,
但是,它仍然无法正常工作,因此我使用以下工具检查了所有文件中的错误:
memory leaks用于测试html文件; locale,用于测试.js文件,https://www.freeformatter.com/java-regex-tester.html,用于测试package.json文件中的错误。
在我纠正了所有文件之后,命令“ npm run build”终于起作用了。 (我特别忘了检查一下script.js文件,我只是从仍然包含脚本标签的html文件中复制了代码)
答案 3 :(得分:0)
问题可能出在您的scripts.js文件中,但首先,请尝试执行 下次测试,一步一步来。
来自package.json ...更改
"imagemin": "imagemin img/* -o dist/img",
到
"imagemin": "imagemin img/* --out-dir dist/img/",
并进行更改(仅添加另一个* .html文件,但现在我们仅尝试使用一个* .html文件)
"usemin": "usemin contactus.html -d dist --htmlmin -o dist/contactus.html",
到
"usemin": "usemin contactus.html -d dist -o dist/contactus.html --htmlmin true",
如果不起作用,请保留更改并尝试执行此操作
从您的* .html ...更改
<!-- build:js js/main.js -->
<script src="node_modules/jquery/dist/jquery.min.js"></script>
<script src="node_modules/tether/dist/js/tether.min.js"></script>
<script src="node_modules/bootstrap/dist/js/bootstrap.min.js"></script>
<script src="js/scripts.js"></script>
<!-- endbuild -->
到
<!-- build:js js/main.js -->
<script src="node_modules/jquery/dist/jquery.min.js"></script>
<script src="node_modules/tether/dist/js/tether.min.js"></script>
<script src="node_modules/bootstrap/dist/js/bootstrap.min.js"></script>
<!-- endbuild -->
<script src="js/scripts.js"></script>
运行
npm run usemin
如果看到dist文件夹以及使用CSS和JS的完整路径 文件夹和html文件;结论是,您需要检查 您的scripts.js文件中JavaScript的语法。
答案 4 :(得分:0)
对于同一课程任务,我也坚持该错误。
我可以通过only
通过重新安装当前版本的usemin-cli
,cssmin
,uglify-js
和htmlmin
开发依赖关系来解决此问题,而无需通过:指定>
sudo npm install --save-dev usemin-cli cssmin uglify-js htmlmin
然后
npm run build
然后我找到了所有包含html的文件,这些文件在dist文件夹内造成了usemin问题。
答案 5 :(得分:-1)
也许是版本错误尝试写入
npm install -g imagemin-cli
代替
npm install -g imagemin-cli@"version"
答案 6 :(得分:-3)
谢谢老兄,我面临着同样的问题,
我所做的是
我从imagemin开始运行各个组件。我有一个错误,所以我跑了
def DeclareList(sort):
List = Datatype('List_of_%s' % sort.name())
List.declare('cons', ('car', sort), ('cdr', List))
List.declare('nil')
return List.create()
IntList = DeclareList(IntSort())
RealList = DeclareList(RealSort())
IntListList = DeclareList(IntList)
接下来,我运行了usemin,并使用单独的html,我发现除了索引其余部分以外,所有html都很好,因此我使用了html验证程序,并在html中发现了一些错误,我修复了这些错误,现在一切正常。