Here is the content of my package.json
file:
{
"name": "deep-playground-prototype",
"version": "2016.3.10",
"description": "",
"private": true,
"scripts": {
"clean": "rimraf dist",
"start": "npm run serve-watch",
"prep": "browserify src/csv.ts -p [tsify] | uglifyjs -c > csv.js && copyfiles analytics.js dist && concat node_modules/material-design-lite/material.min.js node_modules/seedrandom/seedrandom.min.js csv.js > dist/lib.js",
"build-css": "copyfiles fonts.css dist && concat node_modules/material-design-lite/material.min.css styles.css > dist/bundle.css",
"watch-css": "concat node_modules/material-design-lite/material.min.css styles.css -o dist/bundle.css",
"build-html": "copyfiles index.html dist",
"watch-html": "concat index.html -o dist/index.html",
"watch-js": "watchify src/playground.ts -p [tsify] -v --debug -o dist/bundle.js",
"build-js": "browserify src/playground.ts -p [tsify] | uglifyjs -c > dist/bundle.js",
"build": "npm run prep && npm run build-js && npm run build-css && npm run build-html",
"watch": "npm run prep && concurrently \"npm run watch-js\" \"npm run watch-css\" \"npm run watch-html\"",
"serve": "http-server -o -c-1 dist/",
"serve-watch": "concurrently \"http-server -o -c-1 dist/\" \"npm run watch\""
},
"devDependencies": {
"@types/d3": "^3.5.41",
"concat": "^1.0.3",
"concurrently": "3.1.0",
"copyfiles": "1.0.0",
"http-server": "^0.11.1",
"rimraf": "2.5.4",
"tsify": "^4.0.0",
"typescript": "^2.9",
"uglify-js": "^2.8.29",
"watchify": "^3.11.0"
},
"dependencies": {
"@types/jquery": "^3.3.27",
"csv-parse": "^4.2.0",
"csvtojson": "^2.0.8",
"d3": "^3.5.16",
"https-proxy-agent": "^2.2.1",
"material-design-lite": "^1.3.0",
"seedrandom": "^2.4.3",
"typings": "^2.1.1"
}
}
The contents of the csv.ts file are as follows:
import {csv} from 'd3';
async function delay(ms: number) {
return new Promise( resolve => setTimeout(resolve, ms) );
}
export let train = [];
(async()=>{console.log('before delay');csv("training.csv",function(error,data){train = data});await delay(1000);console.log('after delay')})();
I am attempting to load data into a variable called train
initially. Then I am trying to import it from the lib.js
file into the program:
import {train} from 'lib';
However, after compilation, I am encountering the following error:
TypeScript error: src/dataset.ts(17,21): Error TS2307: Cannot find module 'lib'.
It seems like I have missed a step in this process.