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

Can not find '@app/env' when running 'ionic cordova build ios' #22

Open
stevenwaskey opened this issue Feb 6, 2018 · 8 comments
Open

Comments

@stevenwaskey
Copy link

stevenwaskey commented Feb 6, 2018

Ionic fails to build ios application stating that it can not locate the @app/env module. Reluctant to create what is almost a duplicate ticket, I have yet to be able to get to the bottom of this.

Command
ionic serve -l
works without exception.

Command
ionic cordova build ios
fails with following log & error

[13:12:15]  typescript: src/app/app.module.ts, line: 7 
            Cannot find module '@app/env'. 

       L6:  import { QRScanner, QRScannerStatus } from '@ionic-native/qr-scanner';
       L7:  import { ENV } from '@app/env';

[13:12:15]  typescript: src/pages/scanner/scanner.ts, line: 5 
            Cannot find module '@app/env'. 

       L4:  import { AuthenticationService } from '../../services/authentication/authentication-service';
       L5:  import { ENV } from '@app/env';

[13:12:15]  typescript: src/services/authentication/authentication-api.ts, line: 5 
            Cannot find module '@app/env'. 

       L4:  import { Response } from '@angular/http';
       L5:  import { ENV } from '@app/env';

[13:12:15]  typescript: src/services/customers/customers-service.ts, line: 6 
            Cannot find module '@app/env'. 

       L5:  import { Customer } from '../../models/customer';
       L6:  import { ENV } from '@app/env';

Error: Failed to transpile program
    at new BuildError (/Users/swaskey/Sites/dev/dashboard.com/node_modules/@ionic/app-scripts/dist/util/errors.js:16:28)
    at /Users/swaskey/Sites/dev/dashboard.com/node_modules/@ionic/app-scripts/dist/transpile.js:159:20
    at new Promise (<anonymous>)
    at transpileWorker (/Users/swaskey/Sites/dev/dashboard.com/node_modules/@ionic/app-scripts/dist/transpile.js:107:12)
    at Object.transpile (/Users/swaskey/Sites/dev/dashboard.com/node_modules/@ionic/app-scripts/dist/transpile.js:64:12)
    at /Users/swaskey/Sites/dev/dashboard.com/node_modules/@ionic/app-scripts/dist/build.js:109:82
    at <anonymous>

Attempted:
Two different path settings.

...
  "baseUrl": "./src",
  "paths": {
    "@app/env": [
      "environments/environment"
    ]
  }


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

Ionic Info

cli packages: (/Users/swaskey/.npm-global/lib/node_modules)

    @ionic/cli-utils  : 1.19.1
    ionic (Ionic CLI) : 3.19.1

global packages:

    cordova (Cordova CLI) : 8.0.0 

local packages:

    @ionic/app-scripts : 3.1.6
    Cordova Platforms  : browser 5.0.3 ios 4.5.4
    Ionic Framework    : ionic-angular 3.9.2

System:

    Node  : v8.9.3
    npm   : 5.5.1 
    OS    : macOS High Sierra
    Xcode : Xcode 9.2 Build version 9C40b 

Environment Variables:

    ANDROID_HOME : not set

Misc:

    backend : pro
@jbagaresgaray
Copy link

Any news or update on this issue?

@wilfredonoyola
Copy link

wilfredonoyola commented Mar 8, 2018

Hey @jbagaresgaray @stevenwaskey , I have integrated on DEV/PROD, Now It is works correctly!
I think that You will need to update ionic cli and this plugin. Then reinstall platform iOS/Android.

If you have same problem, I will share a project about this later.

@stevenwaskey
Copy link
Author

Unfortunately, we ended up going another route because we were unable to determine & resolve the root cause of the issue. With that said, I'd prefer us to use this plugin.

It appears that Ionic-cli is currently at 3.19.1. And this repo hasn't received an update for at least 3 months. Unless I'm overlooking something, we should have already been using all the latest packages.

@wilfredonoyola
Copy link

I'm not sure why this happens to you, I integrated this last week and the first time I tried this, this worked correctly. However, I will hope that this plugin receive an update.

@AndrWeisR
Copy link

AndrWeisR commented Mar 29, 2018

In your tsconfig.json, make sure that the path that @app/env resolves to actually exists. E.g. with my example below, ensure that you have a file src/environments/environment.DEV.ts. Before I added the "DEV" in my tsconfig.json, I was getting the same Cannot find module '@app/env'. error.

    "baseUrl": "./src",
    "paths": {
      "@app/env": [
        "environments/environment.DEV"
      ]
    }

@cesarin3134
Copy link

I have the same problem, when run
ionic cordova build ios --prod

Module not found: Error: Can't resolve '@app/env' in '/src/pages/home'

@SipGit
Copy link

SipGit commented Jun 14, 2018

Same issue here... :( Any clue .. ?

@borjalo
Copy link

borjalo commented Jun 14, 2018

I've just added every run script I wanted in the package.json, such as:
"staging": "set MY_ENV=staging&& ionic-app-scripts serve", (Windows)
"lab:prod": "set MY_ENV=prod&& ionic lab" (Windows)

"staging": "export MY_ENV=staging&& ionic-app-scripts serve", (MacOS)
"lab:prod": "export MY_ENV=prod&& ionic lab" (MacOS)

and running: npm run {{ name_of_the_script }}
solved the problem

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

7 participants