@Bschuhma wrote:
Hi all,
Hope this isn’t off topic for this forum - if so, please redirect me .
I’ve written a custom class and imported it. The class file, BallotItem.ts - a typescript file, is in node_modules/BallotItem.ts. Things compile fine:
bschuma-MacBookPro1:ttvBMD bret$ ionic serve
Starting app-scripts server: --address 0.0.0.0 --port 8100 --livereload-port 35729 --dev-logger-port 53703
–nobrowser - Ctrl+C to cancel
[17:31:30] watch started …
[17:31:30] build dev started …
[17:31:30] clean started …
[17:31:30] clean finished in 4 ms
[17:31:30] copy started …
[17:31:30] deeplinks started …
[17:31:30] deeplinks finished in 31 ms
[17:31:30] transpile started …
[17:31:33] transpile finished in 2.97 s
[17:31:33] preprocess started …
[17:31:33] preprocess finished in less than 1 ms
[17:31:33] webpack started …
[17:31:33] copy finished in 3.23 s
[17:31:40] webpack finished in 6.18 s
[17:31:40] sass started …
[17:31:41] sass finished in 1.07 s
[17:31:41] postprocess started …
[17:31:41] postprocess finished in 13 ms
[17:31:41] lint started …
[17:31:41] build dev finished in 10.45 s
[17:31:41] watch ready in 10.49 s
[17:31:41] dev server running: http://localhost:8100/[OK] Development server running!
Local: http://localhost:8100
External: http://192.168.1.147:8100
DevApp: ttvBMD@8100 on bschuma-MacBookPro1[17:31:43] lint finished in 2.70 s
However, in the browser, as the app starts, I get this and everything halts:
Error: Module build failed: Error: ENOENT: no such file or directory, open '/Users/bret/TTV/ttvBMD/node_modules/BallotItem.js’
at Object.extend (http://localhost:8100/build/vendor.js:129856:7)
at webpack_require (http://localhost:8100/build/vendor.js:55:30)
at Object.223 (http://localhost:8100/build/main.js:49:69)
at webpack_require (http://localhost:8100/build/vendor.js:55:30)
at Object.308 (http://localhost:8100/build/main.js:230:75)
at webpack_require (http://localhost:8100/build/vendor.js:55:30)
at Object.258 (http://localhost:8100/build/main.js:170:73)
at webpack_require (http://localhost:8100/build/vendor.js:55:30)
at Object.234 (http://localhost:8100/build/main.js:151:70)
at webpack_require (http://localhost:8100/build/vendor.js:55:30)So, I created a *.ts (typescript file) and it’s not finding a *.js of the same name (BallotItem.js).
Where do my custom app classes belong? I had thought they would belong in the app/src directory, but the file cannot be found at all if I put it there . In tsconfig.json I have moduleResolution set to “node”, so node_modules is searched for source files. Sure enough, if I put the custom class there it’s found, but I get the “can’t find *.js” error above.
Any hints? Pointers?
Thanks!
Bret
Posts: 6
Participants: 3