type script, runtime error while trying to import localForage

89 Views Asked by At

i am getting this error after trying to import "localForge": Uncaught TypeError: Error resolving module specifier “localforage”. Relative module specifiers must start with “./”, “../” or “/”.

My tsconfig:

 
{   "compilerOptions": {   
        "outDir": "./dist/",  
        "sourceMap": true,  
        "strict": false,  
        "noImplicitReturns": true,  
        "noImplicitAny": true,  
        "module": "es6",  
        "moduleResolution": "node",  
        "target": "es5",  
        "allowJs": true,  
        "allowSyntheticDefaultImports": true  
    },  
    "include": [  
        "./src/**/*"  
    ]}

import: import * as localForage from "localforage";
also i have tried: import { default as localForage } from "localforage";,
import localForage from "localforage";

1

There are 1 best solutions below

0
zitzennuggler On

Using node modules in the browser does not work right out of the box. Have a look at browserify for example.