Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/node.js/42.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Node.js 针对多个html文件时Usemin创建ELIFECYCLE错误_Node.js_Json_Npm_Node Modules - Fatal编程技术网

Node.js 针对多个html文件时Usemin创建ELIFECYCLE错误

Node.js 针对多个html文件时Usemin创建ELIFECYCLE错误,node.js,json,npm,node-modules,Node.js,Json,Npm,Node Modules,我目前正在Coursera上学习“前端Web UI框架和工具:Bootstrap 4”,遇到了NPM脚本的问题。在my package.json文件中创建脚本以最小化文件并将其传输到分发文件夹时,我在尝试对根文件夹中的三个单独html文件运行usemin脚本时,不断收到ELIFECYCLE错误。就我的一生而言,我不明白为什么我总是犯这样的错误,因为它写得和课堂上教的一模一样。我还尝试在这些文件上单独使用usemin,其中一个文件可以工作,但另外两个不能。如果有任何帮助,我将不胜感激,因为我对编程

我目前正在Coursera上学习“前端Web UI框架和工具:Bootstrap 4”,遇到了NPM脚本的问题。在my package.json文件中创建脚本以最小化文件并将其传输到分发文件夹时,我在尝试对根文件夹中的三个单独html文件运行usemin脚本时,不断收到ELIFECYCLE错误。就我的一生而言,我不明白为什么我总是犯这样的错误,因为它写得和课堂上教的一模一样。我还尝试在这些文件上单独使用usemin,其中一个文件可以工作,但另外两个不能。如果有任何帮助,我将不胜感激,因为我对编程非常缺乏经验,我正试图通过类似这样的在线课程学习更多内容,并且已经被困在这个问题上一周多了。我也无法通过谷歌搜索找到任何关于这个问题的有用信息

{
  "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/",
    "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": {
    "copyfiles": "^2.1.0",
    "cssmin": "^0.4.3",
    "htmlmin": "0.0.7",
    "imagemin": "^6.1.0",
    "lite-server": "^2.3.0",
    "node-sass": "^4.11.0",
    "onchange": "^3.3.0",
    "parallelshell": "^3.0.1",
    "rimraf": "^2.6.2",
    "uglifyjs": "^2.4.11",
    "usemin": "^0.5.0",
    "usemin-cli": "^0.5.1"
  },
  "dependencies": {
    "bootstrap": "^4.0.0",
    "bootstrap-social": "^5.1.1",
    "font-awesome": "^4.7.0",
    "jquery": "^3.3.1",
    "popper.js": "^1.12.9"
  }
}
这是我收到的错误日志:

    0 info it worked if it ends with ok
    1 verbose cli [ 'C:\\Program Files\\nodejs\\node.exe',
    1 verbose cli   'C:\\Users\\User\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js',
    1 verbose cli   'run',
    1 verbose cli   'usemin' ]
    2 info using npm@6.5.0
    3 info using node@v10.13.0
    4 verbose run-script [ 'preusemin', 'usemin', 'postusemin' ]
    5 info lifecycle confusion@1.0.0~preusemin: confusion@1.0.0
    6 info lifecycle confusion@1.0.0~usemin: confusion@1.0.0
    7 verbose lifecycle confusion@1.0.0~usemin: unsafe-perm in lifecycle true
    8 verbose lifecycle confusion@1.0.0~usemin: PATH: C:\Users\User\AppData\Roaming\npm\node_modules\npm\node_modules\npm-lifecycle\node-gyp-bin;C:\Users\User\Desktop\Programming Courses\CoursEra\Front-End Web UI Frameworks and Tools\Bootstrap4\conFusion\node_modules\.bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\Skype\Phone\;C:\Program Files\nodejs\;C:\Program Files\Git\cmd;C:\Program Files\Sublime Text 3;C:\Users\User\AppData\Roaming\npm
    9 verbose lifecycle confusion@1.0.0~usemin: CWD: C:\Users\User\Desktop\Programming Courses\CoursEra\Front-End Web UI Frameworks and Tools\Bootstrap4\conFusion
    10 silly lifecycle confusion@1.0.0~usemin: Args: [ '/d /s /c',
    10 silly lifecycle   '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' ]
    11 silly lifecycle confusion@1.0.0~usemin: Returned: code: 1  signal: null
    12 info lifecycle confusion@1.0.0~usemin: Failed to exec usemin script
    13 verbose stack Error: 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`
    13 verbose stack Exit status 1
    13 verbose stack     at EventEmitter.<anonymous> (C:\Users\User\AppData\Roaming\npm\node_modules\npm\node_modules\npm-lifecycle\index.js:301:16)
    13 verbose stack     at EventEmitter.emit (events.js:182:13)
    13 verbose stack     at ChildProcess.<anonymous> (C:\Users\User\AppData\Roaming\npm\node_modules\npm\node_modules\npm-lifecycle\lib\spawn.js:55:14)
    13 verbose stack     at ChildProcess.emit (events.js:182:13)
    13 verbose stack     at maybeClose (internal/child_process.js:962:16)
    13 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:251:5)
    14 verbose pkgid confusion@1.0.0
    15 verbose cwd C:\Users\User\Desktop\Programming Courses\CoursEra\Front-End Web UI Frameworks and Tools\Bootstrap4\conFusion
    16 verbose Windows_NT 6.1.7601
    17 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\User\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js" "run" "usemin"
    18 verbose node v10.13.0
    19 verbose npm  v6.5.0
    20 error code ELIFECYCLE
    21 error errno 1
    22 error 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`
    22 error Exit status 1
    23 error Failed at the confusion@1.0.0 usemin script.
    23 error This is probably not a problem with npm. There is likely additional logging output above.
    24 verbose exit [ 1, true ]
0信息如果它以ok结尾,它就工作了
1详细cli['C:\\Program Files\\nodejs\\node.exe',
1详细cli'C:\\Users\\User\\AppData\\Roaming\\npm\\node\u modules\\npm\\bin\\npm cli.js',
1详细cli“运行”,
1详细cli“usemin”]
2信息使用npm@6.5.0
3信息使用node@v10.13.0
4详细的运行脚本['preusemin','usemin','postsemin']
5信息生命周期confusion@1.0.0~preusemin:confusion@1.0.0
6信息生命周期confusion@1.0.0~usemin:confusion@1.0.0
7详细的生命周期confusion@1.0.0~usemin:生命周期中的不安全烫发是真的
8详细的生命周期confusion@1.0.0~usemin:PATH:C:\Users\User\AppData\Roaming\npm\node\u modules\npm\node\u modules\npm lifecycle\node gyp bin;C:\Users\User\Desktop\Programming Courses\CoursEra\Front End Web UI Framework and Tools\Bootstrap4\Middle\node\u modules\.bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\ProgramFiles(x86)\Skype\Phone\;C:\ProgramFiles\nodejs\;C:\ProgramFiles\Git\cmd;C:\ProgramFiles\Sublime Text 3;C:\Users\User\AppData\Roaming\npm
9详细的生命周期confusion@1.0.0~usemin:CWD:C:\Users\User\Desktop\Programming Courses\CoursEra\Front End Web UI Frameworks and Tools\Bootstrap4\conflusion
10愚蠢的生命周期confusion@1.0.0~usemin:Args:['/d/s/c',
10“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”]
11愚蠢的生命周期confusion@1.0.0~usemin:Returned:code:1信号:null
12信息生命周期confusion@1.0.0~usemin:无法执行usemin脚本
13详细堆栈错误:confusion@1.0.0usemin:`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`
13详细堆栈退出状态1
13 EventEmitter上的详细堆栈。(C:\Users\User\AppData\Roaming\npm\node\u modules\npm\node\u modules\npm lifecycle\index.js:301:16)
13 EventEmitter.emit上的详细堆栈(events.js:182:13)
13子进程上的详细堆栈。(C:\Users\User\AppData\Roaming\npm\node\u modules\npm\node\u modules\npm lifecycle\lib\spawn.js:55:14)
13 ChildProcess.emit上的详细堆栈(events.js:182:13)
13 maybeClose的详细堆栈(internal/child_process.js:962:16)
13 Process.ChildProcess.\u handle.onexit处的详细堆栈(internal/child\u Process.js:251:5)
14详细的pkgidconfusion@1.0.0
15详细的cwd C:\Users\User\Desktop\Programming Courses\CoursEra\Front End Web UI Framework and Tools\Bootstrap4\Middle
16详细窗口\u NT 6.1.7601
17详细argv“C:\\Program Files\\nodejs\\node.exe”“C:\\Users\\User\\AppData\\Roaming\\npm\\node\U模块\\npm\\bin\\npm cli.js”“运行”“使用分钟”
18详细节点v10.13.0
19详细的npm v6.5.0
20错误代码ELIFECYCLE
21错误1
22错误confusion@1.0.0usemin:`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`
22错误退出状态1
23发生错误时失败confusion@1.0.0使用最小脚本。
23错误这可能不是npm的问题。上面可能还有其他日志输出。
24详细退出[1,true]

我也在做同样的课程,也有类似的错误。然而,我只是能够修复它。为此,我重新安装了所有开发依赖项,并使用了当前版本,而不是本课程中的版本。我还将usemin命令(根据我在这里找到的另一个源代码)更改为

“imagemin”:“imagemin img/*--out dir=dist/img”

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

用于测试html文件,用于测试.js文件和,用于测试package.json文件是否存在错误


在我纠正了所有文件之后,“npm run build”命令终于起作用了。

的“usemin”:“usemin contactus.html-d dist--htmlmin-o dist/contactus.html”;
在package.json文件中单独工作,两者都
的“usemin aboutus.html-d dist--htmlmin-o dist/aboutus.html”;
的“usemin”:“usemin index.html-d dist--htmlmin-o dist/index.html“,
导致ELIFECYCLE错误。在仔细检查和比较我的html文件后,我自己找到了答案。我的两个html文件末尾的脚本标记格式如下。
,而其中一个文件的格式如下:
。在格式化所有文件后,在等号周围没有空格,所有文件在添加到usemin脚本时都能正常工作。感谢您的回复。正如我所说的,我已经解决了这个问题,但是您列出的资源将被删除