简体   繁体   中英

aurelia-cli Unexpected token “<” error when loading plugin

Getting an error trying to load aurelia-dragula (and other plugins) from aurelia-cli.

cli

au-install aurelia-dragula

aurelia.json

        {
            "name": "aurelia-dragula",
            "path": "../node_modules/aurelia-dragula/dist/amd",
            "main": "index"
        },
        ...

.js

import { Dragula } from 'aurelia-dragula';

Error :

vendor-bundle.js:23616 ERROR [app-router] Error: Unexpected token <
Evaluating http://localhost:9000/aurelia-dragula

(it's grabbing the index.html in wwwroot folder and failing on parsing the "DocType" tag)

First thing I'd recommend you to do is upgrade aurelia-cli to the latest version (currently 0.33.1 ).

The unexpected token < is a silly error but it simply means that a non-existing file/url was requested from server (aurelia-dragula in your case). Server returns a standard 404 html page which the app then tries to parse as javascript, and that doesn't work.

Your aurelia.json looks fine (tested it locally on a fresh aurelia-cli project) so it's likely to be either a version or caching issue. After upgrading aurelia-cli I'd recommend deleting the lock files and clearing node_modules, followed by a fresh install.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM