Skip to main content
added 1358 characters in body
Source Link
stackjlei
  • 10.1k
  • 19
  • 75
  • 124

I want to use the pokedex-promise for a pokemonapi but the docs only show you how to require it in vanilla javascript style:

npm install pokedex-promise-v2 --save var Pokedex = require('pokedex-promise-v2'); var P = new Pokedex(); 

How do I use import to get this module? I've tried

import {Pokedex} from 'pokedex-promise-v2' 

and

import Pokedex from 'pokedex-promise-v2' 

but both throw errors with the module:

in ./~/tough-cookie/package.json Module parse failed: /Users/jlei/Desktop/pokeapp/node_modules/tough-cookie/package.json Unexpected token (2:9) You may need an appropriate loader to handle this file type. SyntaxError: Unexpected token (2:9) at Parser.pp$4.raise (/Users/jlei/Desktop/pokeapp/node_modules/acorn/dist/acorn.js:2221:15) at Parser.pp.unexpected (/Users/jlei/Desktop/pokeapp/node_modules/acorn/dist/acorn.js:603:10) at Parser.pp.semicolon (/Users/jlei/Desktop/pokeapp/node_modules/acorn/dist/acorn.js:581:61) at Parser.pp$1.parseExpressionStatement (/Users/jlei/Desktop/pokeapp/node_modules/acorn/dist/acorn.js:966:10) at Parser.pp$1.parseStatement (/Users/jlei/Desktop/pokeapp/node_modules/acorn/dist/acorn.js:730:24) at Parser.pp$1.parseBlock (/Users/jlei/Desktop/pokeapp/node_modules/acorn/dist/acorn.js:981:25) at Parser.pp$1.parseStatement (/Users/jlei/Desktop/pokeapp/node_modules/acorn/dist/acorn.js:709:33) at Parser.pp$1.parseTopLevel (/Users/jlei/Desktop/pokeapp/node_modules/acorn/dist/acorn.js:638:25) at Parser.parse (/Users/jlei/Desktop/pokeapp/node_modules/acorn/dist/acorn.js:516:17) at Object.parse (/Users/jlei/Desktop/pokeapp/node_modules/acorn/dist/acorn.js:3098:39) @ ./~/tough-cookie/lib/cookie.js 38:14-40 

I want to use the pokedex-promise for a pokemonapi but the docs only show you how to require it in vanilla javascript style:

npm install pokedex-promise-v2 --save var Pokedex = require('pokedex-promise-v2'); var P = new Pokedex(); 

How do I use import to get this module? I've tried

import {Pokedex} from 'pokedex-promise-v2' 

and

import Pokedex from 'pokedex-promise-v2' 

but both throw errors with the module

I want to use the pokedex-promise for a pokemonapi but the docs only show you how to require it in vanilla javascript style:

npm install pokedex-promise-v2 --save var Pokedex = require('pokedex-promise-v2'); var P = new Pokedex(); 

How do I use import to get this module? I've tried

import {Pokedex} from 'pokedex-promise-v2' 

and

import Pokedex from 'pokedex-promise-v2' 

but both throw errors with the module:

in ./~/tough-cookie/package.json Module parse failed: /Users/jlei/Desktop/pokeapp/node_modules/tough-cookie/package.json Unexpected token (2:9) You may need an appropriate loader to handle this file type. SyntaxError: Unexpected token (2:9) at Parser.pp$4.raise (/Users/jlei/Desktop/pokeapp/node_modules/acorn/dist/acorn.js:2221:15) at Parser.pp.unexpected (/Users/jlei/Desktop/pokeapp/node_modules/acorn/dist/acorn.js:603:10) at Parser.pp.semicolon (/Users/jlei/Desktop/pokeapp/node_modules/acorn/dist/acorn.js:581:61) at Parser.pp$1.parseExpressionStatement (/Users/jlei/Desktop/pokeapp/node_modules/acorn/dist/acorn.js:966:10) at Parser.pp$1.parseStatement (/Users/jlei/Desktop/pokeapp/node_modules/acorn/dist/acorn.js:730:24) at Parser.pp$1.parseBlock (/Users/jlei/Desktop/pokeapp/node_modules/acorn/dist/acorn.js:981:25) at Parser.pp$1.parseStatement (/Users/jlei/Desktop/pokeapp/node_modules/acorn/dist/acorn.js:709:33) at Parser.pp$1.parseTopLevel (/Users/jlei/Desktop/pokeapp/node_modules/acorn/dist/acorn.js:638:25) at Parser.parse (/Users/jlei/Desktop/pokeapp/node_modules/acorn/dist/acorn.js:516:17) at Object.parse (/Users/jlei/Desktop/pokeapp/node_modules/acorn/dist/acorn.js:3098:39) @ ./~/tough-cookie/lib/cookie.js 38:14-40 
Source Link
stackjlei
  • 10.1k
  • 19
  • 75
  • 124

How to translate require to es6 import/export for node module

I want to use the pokedex-promise for a pokemonapi but the docs only show you how to require it in vanilla javascript style:

npm install pokedex-promise-v2 --save var Pokedex = require('pokedex-promise-v2'); var P = new Pokedex(); 

How do I use import to get this module? I've tried

import {Pokedex} from 'pokedex-promise-v2' 

and

import Pokedex from 'pokedex-promise-v2' 

but both throw errors with the module