Unable to compile typescript on heroku










0















I am trying to deploy a typescript nodejs app using express to heroku, the code is pushed up fine, heroku installs the dependencies and then runs tsc but crashes with src/controller/adminTypes.ts:3:34 - error TS2307: Cannot find module '../repo/adminTypes'..



I checked the line where the import happens and it looks like this



import insertAdminTypes from "../repo/adminTypes";



The equivalent export happens like so



export const insertAdminTypes = async queryObj => 
// code
;


VSCode resolves the paths perfectly fine, when I try running tsc locally everything compiles fine and I get the compiled files in the dist folder. It's only heroku that seems to be throwing an error for the paths online. This doesn't happen for every file, the above TS2307 error is thrown only for a few files.



These are the following config files.



package.json




"name": "express_server",
"version": "0.0.1",
"license": "UNLICENSED",
"main": "./src/server.ts",
"scripts":
"build-ts": "tsc",
"start": "npx nodemon",
"prod": "npx run build-ts",
"postinstall": "npm run build-ts"
,
"dependencies":
"@types/body-parser": "^1.17.0",
"@types/dotenv": "^6.1.0",
"@types/express": "^4.16.0",
"@types/jquery": "^3.3.22",
"@types/node": "^10.12.2",
"@types/underscore": "^1.8.9",
"bcrypt": "^3.0.2",
"body-parser": "^1.18.3",
"dotenv": "^6.1.0",
"express": "^4.16.4",
"express-handlebars": "^3.0.0",
"jsonwebtoken": "^8.3.0",
"mongodb": "^3.1.9",
"mysql": "^2.16.0",
"nodemon": "^1.18.6",
"reflect-metadata": "^0.1.12",
"ts-node": "^7.0.1",
"typeorm": "^0.2.8",
"typescript": "^3.1.6",
"underscore": "^1.9.1"
,
"devDependencies":
"husky": "^1.1.3",
"lint-staged": "^8.0.4",
"prettier": "^1.15.2",
"pretty-quick": "^1.8.0",
"tslint": "^5.11.0",
"tslint-config-prettier": "^1.15.0",
"tslint-plugin-prettier": "^2.0.1"
,
"husky":
"hooks":
"pre-commit": "pretty-quick --staged"

,
"lint-staged":
"linters":
"*.ts": [
"npx tslint --fix",
"git add"
]
,
"ignore": [
"./public",
"./environment",
"./node_modules"
]




nodemon.json




"ignore": ["**/*.test.ts", "**/*.spec.ts", ".git", "node_modules"],
"watch": ["src"],
"exec": "npx ts-node ./src/server.ts",
"ext": "ts"



tsconfig.json




"compilerOptions":
"module": "commonjs",
"esModuleInterop": true,
"target": "es6",
"noImplicitAny": false,
"moduleResolution": "node",
"sourceMap": true,
"outDir": "dist",
"pretty": true,
"baseUrl": ".",
"alwaysStrict": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"paths":
"*": ["node_modules/*", "src/types/*"]

,
"include": ["src/**/*.ts"],
"exclude": ["node_modules"]










share|improve this question

















  • 1





    A standard troubleshooting step: enable the traceResolution compiler option and look at the output.

    – Matt McCutchen
    Nov 14 '18 at 17:07















0















I am trying to deploy a typescript nodejs app using express to heroku, the code is pushed up fine, heroku installs the dependencies and then runs tsc but crashes with src/controller/adminTypes.ts:3:34 - error TS2307: Cannot find module '../repo/adminTypes'..



I checked the line where the import happens and it looks like this



import insertAdminTypes from "../repo/adminTypes";



The equivalent export happens like so



export const insertAdminTypes = async queryObj => 
// code
;


VSCode resolves the paths perfectly fine, when I try running tsc locally everything compiles fine and I get the compiled files in the dist folder. It's only heroku that seems to be throwing an error for the paths online. This doesn't happen for every file, the above TS2307 error is thrown only for a few files.



These are the following config files.



package.json




"name": "express_server",
"version": "0.0.1",
"license": "UNLICENSED",
"main": "./src/server.ts",
"scripts":
"build-ts": "tsc",
"start": "npx nodemon",
"prod": "npx run build-ts",
"postinstall": "npm run build-ts"
,
"dependencies":
"@types/body-parser": "^1.17.0",
"@types/dotenv": "^6.1.0",
"@types/express": "^4.16.0",
"@types/jquery": "^3.3.22",
"@types/node": "^10.12.2",
"@types/underscore": "^1.8.9",
"bcrypt": "^3.0.2",
"body-parser": "^1.18.3",
"dotenv": "^6.1.0",
"express": "^4.16.4",
"express-handlebars": "^3.0.0",
"jsonwebtoken": "^8.3.0",
"mongodb": "^3.1.9",
"mysql": "^2.16.0",
"nodemon": "^1.18.6",
"reflect-metadata": "^0.1.12",
"ts-node": "^7.0.1",
"typeorm": "^0.2.8",
"typescript": "^3.1.6",
"underscore": "^1.9.1"
,
"devDependencies":
"husky": "^1.1.3",
"lint-staged": "^8.0.4",
"prettier": "^1.15.2",
"pretty-quick": "^1.8.0",
"tslint": "^5.11.0",
"tslint-config-prettier": "^1.15.0",
"tslint-plugin-prettier": "^2.0.1"
,
"husky":
"hooks":
"pre-commit": "pretty-quick --staged"

,
"lint-staged":
"linters":
"*.ts": [
"npx tslint --fix",
"git add"
]
,
"ignore": [
"./public",
"./environment",
"./node_modules"
]




nodemon.json




"ignore": ["**/*.test.ts", "**/*.spec.ts", ".git", "node_modules"],
"watch": ["src"],
"exec": "npx ts-node ./src/server.ts",
"ext": "ts"



tsconfig.json




"compilerOptions":
"module": "commonjs",
"esModuleInterop": true,
"target": "es6",
"noImplicitAny": false,
"moduleResolution": "node",
"sourceMap": true,
"outDir": "dist",
"pretty": true,
"baseUrl": ".",
"alwaysStrict": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"paths":
"*": ["node_modules/*", "src/types/*"]

,
"include": ["src/**/*.ts"],
"exclude": ["node_modules"]










share|improve this question

















  • 1





    A standard troubleshooting step: enable the traceResolution compiler option and look at the output.

    – Matt McCutchen
    Nov 14 '18 at 17:07













0












0








0








I am trying to deploy a typescript nodejs app using express to heroku, the code is pushed up fine, heroku installs the dependencies and then runs tsc but crashes with src/controller/adminTypes.ts:3:34 - error TS2307: Cannot find module '../repo/adminTypes'..



I checked the line where the import happens and it looks like this



import insertAdminTypes from "../repo/adminTypes";



The equivalent export happens like so



export const insertAdminTypes = async queryObj => 
// code
;


VSCode resolves the paths perfectly fine, when I try running tsc locally everything compiles fine and I get the compiled files in the dist folder. It's only heroku that seems to be throwing an error for the paths online. This doesn't happen for every file, the above TS2307 error is thrown only for a few files.



These are the following config files.



package.json




"name": "express_server",
"version": "0.0.1",
"license": "UNLICENSED",
"main": "./src/server.ts",
"scripts":
"build-ts": "tsc",
"start": "npx nodemon",
"prod": "npx run build-ts",
"postinstall": "npm run build-ts"
,
"dependencies":
"@types/body-parser": "^1.17.0",
"@types/dotenv": "^6.1.0",
"@types/express": "^4.16.0",
"@types/jquery": "^3.3.22",
"@types/node": "^10.12.2",
"@types/underscore": "^1.8.9",
"bcrypt": "^3.0.2",
"body-parser": "^1.18.3",
"dotenv": "^6.1.0",
"express": "^4.16.4",
"express-handlebars": "^3.0.0",
"jsonwebtoken": "^8.3.0",
"mongodb": "^3.1.9",
"mysql": "^2.16.0",
"nodemon": "^1.18.6",
"reflect-metadata": "^0.1.12",
"ts-node": "^7.0.1",
"typeorm": "^0.2.8",
"typescript": "^3.1.6",
"underscore": "^1.9.1"
,
"devDependencies":
"husky": "^1.1.3",
"lint-staged": "^8.0.4",
"prettier": "^1.15.2",
"pretty-quick": "^1.8.0",
"tslint": "^5.11.0",
"tslint-config-prettier": "^1.15.0",
"tslint-plugin-prettier": "^2.0.1"
,
"husky":
"hooks":
"pre-commit": "pretty-quick --staged"

,
"lint-staged":
"linters":
"*.ts": [
"npx tslint --fix",
"git add"
]
,
"ignore": [
"./public",
"./environment",
"./node_modules"
]




nodemon.json




"ignore": ["**/*.test.ts", "**/*.spec.ts", ".git", "node_modules"],
"watch": ["src"],
"exec": "npx ts-node ./src/server.ts",
"ext": "ts"



tsconfig.json




"compilerOptions":
"module": "commonjs",
"esModuleInterop": true,
"target": "es6",
"noImplicitAny": false,
"moduleResolution": "node",
"sourceMap": true,
"outDir": "dist",
"pretty": true,
"baseUrl": ".",
"alwaysStrict": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"paths":
"*": ["node_modules/*", "src/types/*"]

,
"include": ["src/**/*.ts"],
"exclude": ["node_modules"]










share|improve this question














I am trying to deploy a typescript nodejs app using express to heroku, the code is pushed up fine, heroku installs the dependencies and then runs tsc but crashes with src/controller/adminTypes.ts:3:34 - error TS2307: Cannot find module '../repo/adminTypes'..



I checked the line where the import happens and it looks like this



import insertAdminTypes from "../repo/adminTypes";



The equivalent export happens like so



export const insertAdminTypes = async queryObj => 
// code
;


VSCode resolves the paths perfectly fine, when I try running tsc locally everything compiles fine and I get the compiled files in the dist folder. It's only heroku that seems to be throwing an error for the paths online. This doesn't happen for every file, the above TS2307 error is thrown only for a few files.



These are the following config files.



package.json




"name": "express_server",
"version": "0.0.1",
"license": "UNLICENSED",
"main": "./src/server.ts",
"scripts":
"build-ts": "tsc",
"start": "npx nodemon",
"prod": "npx run build-ts",
"postinstall": "npm run build-ts"
,
"dependencies":
"@types/body-parser": "^1.17.0",
"@types/dotenv": "^6.1.0",
"@types/express": "^4.16.0",
"@types/jquery": "^3.3.22",
"@types/node": "^10.12.2",
"@types/underscore": "^1.8.9",
"bcrypt": "^3.0.2",
"body-parser": "^1.18.3",
"dotenv": "^6.1.0",
"express": "^4.16.4",
"express-handlebars": "^3.0.0",
"jsonwebtoken": "^8.3.0",
"mongodb": "^3.1.9",
"mysql": "^2.16.0",
"nodemon": "^1.18.6",
"reflect-metadata": "^0.1.12",
"ts-node": "^7.0.1",
"typeorm": "^0.2.8",
"typescript": "^3.1.6",
"underscore": "^1.9.1"
,
"devDependencies":
"husky": "^1.1.3",
"lint-staged": "^8.0.4",
"prettier": "^1.15.2",
"pretty-quick": "^1.8.0",
"tslint": "^5.11.0",
"tslint-config-prettier": "^1.15.0",
"tslint-plugin-prettier": "^2.0.1"
,
"husky":
"hooks":
"pre-commit": "pretty-quick --staged"

,
"lint-staged":
"linters":
"*.ts": [
"npx tslint --fix",
"git add"
]
,
"ignore": [
"./public",
"./environment",
"./node_modules"
]




nodemon.json




"ignore": ["**/*.test.ts", "**/*.spec.ts", ".git", "node_modules"],
"watch": ["src"],
"exec": "npx ts-node ./src/server.ts",
"ext": "ts"



tsconfig.json




"compilerOptions":
"module": "commonjs",
"esModuleInterop": true,
"target": "es6",
"noImplicitAny": false,
"moduleResolution": "node",
"sourceMap": true,
"outDir": "dist",
"pretty": true,
"baseUrl": ".",
"alwaysStrict": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"paths":
"*": ["node_modules/*", "src/types/*"]

,
"include": ["src/**/*.ts"],
"exclude": ["node_modules"]







node.js typescript express heroku typescript-typings






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 14 '18 at 16:22









Jude FernandesJude Fernandes

2,78852351




2,78852351







  • 1





    A standard troubleshooting step: enable the traceResolution compiler option and look at the output.

    – Matt McCutchen
    Nov 14 '18 at 17:07












  • 1





    A standard troubleshooting step: enable the traceResolution compiler option and look at the output.

    – Matt McCutchen
    Nov 14 '18 at 17:07







1




1





A standard troubleshooting step: enable the traceResolution compiler option and look at the output.

– Matt McCutchen
Nov 14 '18 at 17:07





A standard troubleshooting step: enable the traceResolution compiler option and look at the output.

– Matt McCutchen
Nov 14 '18 at 17:07












1 Answer
1






active

oldest

votes


















0














Found the issue, it turns out I wasn't paying attention to the filename ie, the case.



For example the error being thrown as described above Cannot find module '../repo/adminTypes' was due to the face that the actual filename was AdminTypes, capital A.



VSCode/ Windows was auto handling case sensitivity so it never threw an error but when deployed to heroku, the server was very strict with filenames.






share|improve this answer






















    Your Answer






    StackExchange.ifUsing("editor", function ()
    StackExchange.using("externalEditor", function ()
    StackExchange.using("snippets", function ()
    StackExchange.snippets.init();
    );
    );
    , "code-snippets");

    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "1"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader:
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    ,
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );













    draft saved

    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53304645%2funable-to-compile-typescript-on-heroku%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    Found the issue, it turns out I wasn't paying attention to the filename ie, the case.



    For example the error being thrown as described above Cannot find module '../repo/adminTypes' was due to the face that the actual filename was AdminTypes, capital A.



    VSCode/ Windows was auto handling case sensitivity so it never threw an error but when deployed to heroku, the server was very strict with filenames.






    share|improve this answer



























      0














      Found the issue, it turns out I wasn't paying attention to the filename ie, the case.



      For example the error being thrown as described above Cannot find module '../repo/adminTypes' was due to the face that the actual filename was AdminTypes, capital A.



      VSCode/ Windows was auto handling case sensitivity so it never threw an error but when deployed to heroku, the server was very strict with filenames.






      share|improve this answer

























        0












        0








        0







        Found the issue, it turns out I wasn't paying attention to the filename ie, the case.



        For example the error being thrown as described above Cannot find module '../repo/adminTypes' was due to the face that the actual filename was AdminTypes, capital A.



        VSCode/ Windows was auto handling case sensitivity so it never threw an error but when deployed to heroku, the server was very strict with filenames.






        share|improve this answer













        Found the issue, it turns out I wasn't paying attention to the filename ie, the case.



        For example the error being thrown as described above Cannot find module '../repo/adminTypes' was due to the face that the actual filename was AdminTypes, capital A.



        VSCode/ Windows was auto handling case sensitivity so it never threw an error but when deployed to heroku, the server was very strict with filenames.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 14 '18 at 20:54









        Jude FernandesJude Fernandes

        2,78852351




        2,78852351





























            draft saved

            draft discarded
















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid


            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.

            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53304645%2funable-to-compile-typescript-on-heroku%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            這個網誌中的熱門文章

            How to read a connectionString WITH PROVIDER in .NET Core?

            In R, how to develop a multiplot heatmap.2 figure showing key labels successfully

            Museum of Modern and Contemporary Art of Trento and Rovereto