Reputation: 5761
I have an ASP.NET Core RC1 project that no longer publishes correctly (see publish trace output, below). The gulp min
task in the prepublish script defined in project.json
is causing the error. If I remove it, the project publishes correctly, but without minifying the js and css files.
"scripts": {
"prepublish": [ "npm install", "bower install", "gulp clean", "gulp min" ]
}
I have added another Web Project to the solution, and that publishes without error, so I think that eliminates environmental issues. However, I can't see anything substantially different between the test project and the one that fails.
I have also deleted the node_modules
folder in the failing project to force Visual Studio to download all the npm packages again.
Finally I ran the dnu publish
command in the trace below from the VS command prompt and that also failed.
Can anyone tell me what the problem is from the error trace below, please?
Connecting to C:\svn\Client Applications\yyy\xxx\src\xxxWeb\..\..\artifacts\bin\xxx.Web\Release\PublishOutput...
Environment variables:
Path=.\node_modules\.bin;C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\Extensions\Microsoft\Web Tools\External;%PATH%;C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\Extensions\Microsoft\Web Tools\External\git
C:\Users\ptayl_000\.dnx\runtimes\dnx-clr-win-x86.1.0.0-rc1-final\bin\dnu.cmd publish "C:\svn\Client Applications\yyy\xxx\src\xxxWeb" --out "C:\Users\ptayl_000\AppData\Local\Temp\PublishTemp\xxx.Web104" --configuration Release --no-source --runtime dnx-clr-win-x86.1.0.0-rc1-final --wwwroot "wwwroot" --wwwroot-out "wwwroot" --iis-command "web" --quiet
Microsoft .NET Development Utility Clr-x86-1.0.0-rc1-16202
Executing script 'prepublish' in project.json
v0.10.31
npm WARN package.json [email protected] No description
npm WARN package.json [email protected] No repository field.
npm WARN package.json [email protected] No README data
[07:36:31] Using gulpfile C:\svn\Client Applications\yyy\xxx\src\xxxWeb\gulpfile.js
[07:36:31] Starting 'clean:js'...
[07:36:31] Starting 'clean:css'...
[07:36:31] Finished 'clean:js' after 1.68 ms
[07:36:31] Finished 'clean:css' after 1.99 ms
[07:36:31] Starting 'clean'...
[07:36:31] Finished 'clean' after 9.03 μs
[07:36:32] Using gulpfile C:\svn\Client Applications\yyy\xxx\src\xxxWeb\gulpfile.js
[07:36:32] Starting 'min:js'...
[07:36:32] Starting 'min:css'...
[07:36:32] Finished 'min:css' after 61 ms
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\Web\Microsoft.DNX.Publishing.targets(152,5): Error : events.js:72
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\Web\Microsoft.DNX.Publishing.targets(152,5): Error : throw er; // Unhandled 'error' event
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\Web\Microsoft.DNX.Publishing.targets(152,5): Error : ^
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\Web\Microsoft.DNX.Publishing.targets(152,5): Error : Error
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\Web\Microsoft.DNX.Publishing.targets(152,5): Error : at new JS_Parse_Error (C:\svn\Client Applications\yyy\xxx\src\xxxWeb\node_modules\gulp-uglify\node_modules\uglify-js\lib\parse.js:196:18)
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\Web\Microsoft.DNX.Publishing.targets(152,5): Error : at js_error (C:\svn\Client Applications\yyy\xxx\src\xxxWeb\node_modules\gulp-uglify\node_modules\uglify-js\lib\parse.js:204:11)
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\Web\Microsoft.DNX.Publishing.targets(152,5): Error : at croak (C:\svn\Client Applications\yyy\xxx\src\xxxWeb\node_modules\gulp-uglify\node_modules\uglify-js\lib\parse.js:675:9)
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\Web\Microsoft.DNX.Publishing.targets(152,5): Error : at token_error (C:\svn\Client Applications\yyy\xxx\src\xxxWeb\node_modules\gulp-uglify\node_modules\uglify-js\lib\parse.js:683:9)
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\Web\Microsoft.DNX.Publishing.targets(152,5): Error : at expect_token (C:\svn\Client Applications\yyy\xxx\src\xxxWeb\node_modules\gulp-uglify\node_modules\uglify-js\lib\parse.js:696:9)
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\Web\Microsoft.DNX.Publishing.targets(152,5): Error : at expect (C:\svn\Client Applications\yyy\xxx\src\xxxWeb\node_modules\gulp-uglify\node_modules\uglify-js\lib\parse.js:699:36)
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\Web\Microsoft.DNX.Publishing.targets(152,5): Error : at C:\svn\Client Applications\yyy\xxx\src\xxxWeb\node_modules\gulp-uglify\node_modules\uglify-js\lib\parse.js:1252:13
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\Web\Microsoft.DNX.Publishing.targets(152,5): Error : at C:\svn\Client Applications\yyy\xxx\src\xxxWeb\node_modules\gulp-uglify\node_modules\uglify-js\lib\parse.js:722:24
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\Web\Microsoft.DNX.Publishing.targets(152,5): Error : at expr_atom (C:\svn\Client Applications\yyy\xxx\src\xxxWeb\node_modules\gulp-uglify\node_modules\uglify-js\lib\parse.js:1182:35)
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\Web\Microsoft.DNX.Publishing.targets(152,5): Error : at maybe_unary (C:\svn\Client Applications\yyy\xxx\src\xxxWeb\node_modules\gulp-uglify\node_modules\uglify-js\lib\parse.js:1358:19)
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\Web\Microsoft.DNX.Publishing.targets(152,5): Error : The 'prepublish' script failed with status code 8.
2>Publish failed due to build errors. Check the error list for more details.
Update
The gulp min
task contains the following code (from gulp.js
):
gulp.task("min:js", function () {
return gulp.src([paths.js, "!" + paths.minJs], { base: "." })
.pipe(concat(paths.concatJsDest))
.pipe(uglify())
.pipe(gulp.dest("."));
});
Update2: event.js
var rx = require("rx");
function normalizeKeypressEvents(args) {
return { value: args[0], key: args[1] };
}
module.exports = function(rl) {
return {
line: rx.Observable.fromEvent(rl, "line"),
keypress: rx.Observable.fromEvent(rl, "keypress", normalizeKeypressEvents),
normalizedUpKey: rx.Observable.fromEvent(rl, "keypress", normalizeKeypressEvents).filter(function (e) {
return e.key && (e.key.name === "up" || e.key.name === "k");
}).share(),
normalizedDownKey: rx.Observable.fromEvent(rl, "keypress", normalizeKeypressEvents).filter(function (e) {
return e.key && (e.key.name === "down" || e.key.name === "j");
}).share(),
numberKey: rx.Observable.fromEvent(rl, "keypress", normalizeKeypressEvents).filter(function (e) {
return e.value && "123456789".indexOf(e.value) >= 0;
}).map(function(e) {
return Number(e.value);
}).share(),
spaceKey: rx.Observable.fromEvent(rl, "keypress", normalizeKeypressEvents).filter(function (e) {
return e.key && e.key.name === "space";
}).share(),
};
};
Upvotes: 2
Views: 963
Reputation: 467
I was getting the same issues (even on the same line numbers). Paul's own answer gave me a clue to look carefully at my own .js
I commented out most of the file and then progressively uncommented blocks of code until the errors came back.
And the offending code? This line that uses a template string was the problem:
rtUl.insertAdjacentHTML("beforeend", `<li>${el.toString()}</li>`);
Changing it back to a simple concatenation worked:
rtUl.insertAdjacentHTML("beforeend", "<li>" + el.toString() + "</li>");
It seems that uglify can't read string templates (yet).
Upvotes: 1
Reputation: 5761
Turned out that it was a piece of application javascript that was causing the "gulp min" task to fail. The culprit was the following seemingly innocuous piece of code:
$http.get(uri, { params: { config } }).then(function (data) {
return data;
});
I still can't see any problem with it, but as the code had become redundant, I removed it and solved the problem that way.
Upvotes: 1