Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot find module '@app/env'. #21

Closed
wiadev opened this issue Jan 25, 2018 · 7 comments
Closed

Cannot find module '@app/env'. #21

wiadev opened this issue Jan 25, 2018 · 7 comments

Comments

@wiadev
Copy link

wiadev commented Jan 25, 2018

I've followed your steps but got the error can't find a module.

I've kept the config.dev.ts and config.prod.ts under ./config.
tsconfig.json

"baseUrl":  "./config",
    "paths": {
      "@app/env": ["config"]
    },

webpack.config.js

var path = require('path');
var useDefaultConfig = require('@ionic/app-scripts/config/webpack.config.js');
module.exports = function () {
    useDefaultConfig[process.env.IONIC_ENV].resolve.alias = {
        "@app/env": path.resolve(__dirname + '/config.' + process.env.IONIC_ENV + '.ts'),
    };
    return useDefaultConfig;
};

These are the same as you mentioned in README but still can't find a module.

Ionic v3.9.3

@enolcasielles
Copy link

Have you put baseUrl and paths inside compilerOptions object in tsconfig.json file? I had same error and this was the reason.

@wiadev
Copy link
Author

wiadev commented Jan 26, 2018

@enolcasielles yes, I did.

"baseUrl":  "./config",
    "paths": {
      "@app/env": ["config"]
    },

I've followed the example in readme precisely and it worked but not sure why the above case is not working.

@enolcasielles
Copy link

Could be because you are indexing file from root directory instead config folder? Maybe you should change by:

"@app/env": path.resolve(__dirname + 'config/config.' + process.env.IONIC_ENV + '.ts'),

@wiadev
Copy link
Author

wiadev commented Jan 26, 2018

@enolcasielles Thanks

@wiadev wiadev closed this as completed Jan 26, 2018
@aronAtWex
Copy link

Out of the blue I'm getting the same problem. Google lead me here.

Created a new thread
#39

@0x14Rp
Copy link

0x14Rp commented Apr 14, 2021

Could be because you are indexing file from root directory instead config folder? Maybe you should change by:

"@app/env": path.resolve(__dirname + 'config/config.' + process.env.IONIC_ENV + '.ts'),

this solution is not working?i am looking for something so i need to change environments when doing the build

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants