简体   繁体   中英

ionic 2: ionic run android shows error

i have error when i run "ionic run android" or "ionic build android" in my ionic 2 app this is the error i get. i just tryinh to see my app in the emulator of android. i tried to make new ionic 2 project but it's the same problem.

Running 'build:before' npm script before build
> ionic-hello-world@ build C:\Users\Adir\MyApps\tasklist
> ionic-app-scripts build --rollup ./config/rollup.config.js
[20:16:33]  ionic-app-scripts 0.0.30
[20:16:33]  build prod started ...
[20:16:33]  clean started ...
[20:16:33]  clean finished in 24 ms
[20:16:33]  copy started ...
[20:16:33]  ngc started ...
[20:16:33]  lint started ...
[20:16:33]  copy finished in 182 ms
[20:16:34]  lint finished in 770 ms
[20:16:52]  ngc finished in 18.71 s
[20:16:52]  bundle prod started ...
[20:16:52]  bundle prod failed:  Could not resolve entry (/app/main.prod.ts)

[20:16:52]  Error: Could not resolve entry (/app/main.prod.ts)
    at C:\Users\Adir\MyApps\tasklist\node_modules\rollup\dist\rollup.js:8635:28
    at process._tickCallback (internal/process/next_tick.js:103:7)

Error running ionic app script "build": Error: Could not resolve entry (/app/main.prod.ts)



npm
 ERR! Windows_NT 10.0.14393

npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "run" "build"
npm ERR! node v6.7.0
npm ERR! npm  v3.10.3
npm ERR! code ELIFECYCLE
npm ERR! ionic-hello-world@ build: `ionic-app-scripts build --rollup ./config/rollup.config.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the ionic-hello-world@ build script 'ionic-app-scripts build --rollup ./config/rollup.config.js'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the ionic-hello-world package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!
     ionic-app-scripts build --rollup ./config/rollup.config.js
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs ionic-hello-world
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls ionic-hello-world
npm ERR! There is likely additional logging output above.



npm ERR! Please include the following file with any support request:
npm ERR!     C:\Users\Adir\MyApps\tasklist\npm-debug.log

Caught exception:
 undefined

Mind letting us know? https://github.com/driftyco/ionic-cli/issues


C:\Users\Adir\MyApps\tasklist>

This has been a common issue lately with ionic and A2 and resolving main.prod.* Try updating you app scripts for the project.

npm install @ionic/app-scripts@latest

Your error message should change after that with what is actually causing your build to crash. If the error message changes please update your question with the new message.

Checkout this out as well for more information on this issue: Ionic forum

Close all ionic folders and serve or lab. And try again, ionic cordova build android .

There is a path setup problem in your system.

1st check npm version using CMD: npm -v

If it shows version number then use below code, otherwise 1st setup your npm path, you can use gitbash cmd, nodejs cmd

Try to use

ionic cordova run android 

or

ionic cordova platform remove android

ionic cordova run android

If you have MAC system must use sudo like

sudo ionic cordova run android

First of all, Check the version of Android in package.json file.

Now remove platform with this command (ionic cordova platform rm android)

After that addd the platform with this command (ionic cordova platform add

android@6.4.0). Where 7.0.0 is not stable version so use 6.4.0

Now, run this command (ionic cordova run android) or in mac (sudo ionic cordova run android)

Try out below command

$ cordova clean android
$ cordova build android
$ ionic cordova build android

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM