Closed jrmora closed 6 years ago
@jrmora Thanks for reporting your issue. Because I'm using ES6 exports, it is possible you have to use:
var ChordSheetJS = require('chordsheetjs').default;
Could you try this? Please let me know if this works.
It does not work. :( The problem does not seem to be in the import but in the "new".
I made it work, following this tutorial: https://basarat.gitbooks.io/typescript/docs/quick/nodejs.html
npm init -y
npm install typescript --save-dev
npm install @types/node --save-dev
node ./node_modules/typescript/lib/tsc --init
npm install ts-node --save-dev
npm install nodemon --save-dev
"scripts": {
"start": "npm run build:live",
"build:live": "nodemon --exec ./node_modules/.bin/ts-node -- ./app.ts"
},
8. `npm install chordsheetjs --save-dev`
9. Create the app.ts (with your modification on require):
var ChordSheetJS = require('chordsheetjs').default;
const chordSheet = Am C/G F C Let it be, let it be, let it be, let it be C G F C/E Dm C Whisper words of wisdom, let it be
.substring(1);
const parser = new ChordSheetJS.ChordSheetParser(); const song = parser.parse(chordSheet); const formatter = new ChordSheetJS.ChordProFormatter(); const disp = formatter.format(song); console.log(disp);
10. `npm start`
I try to execute it with a basic typescript file as follows:
1) tsc --init 2) npm install chordsheetjs 3) create a file app.ts with :
var ChordSheetJS = require('chordsheetjs'); const parser = new ChordSheetJS.ChordSheetParser();
4) In order to allow the 'require' function :
npm install @types/node --save
5) Compile the typescript with success:
tsc
6)Execute with: node app.js
ERROR: ChordSheetJS.ChordSheetParser is not a constructor
May you put an example to test your library? Thank you.