1

I've installed Highway using the terminal and when I run the following script:

import Highway from '@dogstudio/highway';
import Fade from './transition';

const H = new Highway.core({
  transition: {
    default: Fade
  }
});

The first line throws the following error:

Uncaught SyntaxError: Unexpected identifier

What am I doing wrong?

Malekai
  • 4,765
  • 5
  • 25
  • 60
JolHaricot
  • 23
  • 5

1 Answers1

0

Looking at this code, there could be several possible reasons as to why this isn't working.

1. Importing the package properly:

Try changing the first two lines to this:

import { Highway } from '@dogstudio/highway';
import { Fade } from './transition';

2. Installing the package properly:

Over on the installation documentation (for Highway) it says to install it using NPM, you'd use the following command:

npm install --save-dev @dogstudio/highway

You'd then import Highway as you did before, like this:

import Highway from '@dogstudio/highway';

WARNING: if you get a "permissions error" you'll have to use sudo (put it before npm) to grant your user access files/folders that require elevated privileges.

3. Setting up an NPM project:

Use npm init -y to set up an npm project in your current directory, omit the -y option to manually make the decisions.

Good luck.

Malekai
  • 4,765
  • 5
  • 25
  • 60
  • I used the command said on the highway website and your command, it says the same thing for both "+ @dogstudio/highway@2.1.2 updated 1 package and audited 2320 packages in 9.558s found 0 vulnerabilities" and the error line line is still there – JolHaricot May 20 '19 at 10:24
  • I think I might have found the problem and I've updated my answer, can you try the first suggestion? Don't hesitate to let me know if it doesn't work. – Malekai May 20 '19 at 12:10
  • In visual code, if my mouse is on the '@' of @dogstudio/highway, I see : module "d:/Projets Programmation/page-transitions-js-master/node_modules/@dogstudio/highway/build/highway" Could not find a declaration file for module '@dogstudio/highway'. 'd:/Projets Programmation/page-transitions-js-master/node_modules/@dogstudio/highway/build/highway.js' implicitly has an 'any' type. Try `npm install @types/dogstudio__highway` if it exists or add a new declaration (.d.ts) file containing `declare module '@dogstudio/highway';`ts(7016) – JolHaricot May 20 '19 at 15:40
  • npm install @types/dogstudio__highway I tried it but it said npm ERR! A complete log of this run can be found in: . So the package is installed ? – JolHaricot May 20 '19 at 15:41
  • @JolHaricot Please don't post duplicate comments and no it isn't installed, edit your question then add the contents of your `package.log` file, then let me know. – Malekai May 21 '19 at 05:49