vaadin / vaadin-gradle-plugin

Gradle plugin for Vaadin 14 applications. Takes care of front-end build, helps to configure repositories and to create various project and file templates.
Apache License 2.0
31 stars 9 forks source link

vaadinPrepareFrontend fails with Invalid object #104

Open mcooper7290 opened 3 years ago

mcooper7290 commented 3 years ago

Desktop (please complete the following information):

Describe the bug When building target 'vaadinPrepareFrontend' the build fails with Invalid object:

Task :WebApp:vaadinPrepareFrontend FAILED

FAILURE: Build failed with an exception.

This occurs when running 'gradle --stop; gradle clean assemble vaadinPrepareFrontend'

The same command with --stacktrace is attached.

build-stacktrace.txt

To Reproduce Steps to reproduce the behavior:

  1. Setup project '...'
  2. Run Gradle task '....''
  3. See error '....'

Expected behavior A clear and concise description of what you expected to happen.

Screenshots If applicable, add screenshots to help explain your problem.

Additional context Add any other context about the problem here.

mcooper7290 commented 3 years ago

Ignore build-stacktrace.txt - that's the wrong file. Here is the correct build with stacktrace. build-stacktrace2.txt

mcooper7290 commented 3 years ago

I fixed my issue by deleting all the project .js and node_modules/ files. It would be nice if the exception was caught and output the name of the file it can't parse.

mvysny commented 3 years ago

From the stacktrace

Caused by: elemental.json.JsonException: Invalid object: 
    at elemental.json.impl.JsonTokenizer.parseObject(JsonTokenizer.java:275)
    at elemental.json.impl.JsonTokenizer.nextValue(JsonTokenizer.java:173)
    at elemental.json.impl.JsonTokenizer.parseObject(JsonTokenizer.java:231)
    at elemental.json.impl.JsonTokenizer.nextValue(JsonTokenizer.java:173)
    at elemental.json.impl.JsonTokenizer.parseObject(JsonTokenizer.java:231)
    at elemental.json.impl.JsonTokenizer.nextValue(JsonTokenizer.java:173)
    at elemental.json.impl.JreJsonFactory.parse(JreJsonFactory.java:64)
    at elemental.json.Json.parse(Json.java:53)
    at com.vaadin.flow.server.frontend.NodeUpdater.getJsonFileContent(NodeUpdater.java:209)
    at com.vaadin.flow.server.frontend.NodeUpdater.getPackageJson(NodeUpdater.java:192)
    at com.vaadin.flow.server.frontend.TaskCreatePackageJson.execute(TaskCreatePackageJson.java:47)

it can be seen that Vaadin is trying to parse the package.json and is failing for some reason. I'm guessing that the file must have had some funny non-JSON contents for some reason.

However, certainly Vaadin should have reported this error in a much more cleaner way. Could you please open a bug report at https://github.com/vaadin/flow/issues in this regard?

mvysny commented 3 years ago

Reported upstream: https://github.com/vaadin/flow/issues/10323