【问题标题】:ionic 2: ionic run android shows error离子 2:离子运行 android 显示错误
【发布时间】:2018-08-09 07:06:33
【问题描述】:

在我的 ionic 2 应用程序中运行“ionic run android”或“ionic build android”时出现错误 这是我得到的错误。我只是试着在 android 的模拟器中查看我的应用程序。 我尝试制作新的 ionic 2 项目,但问题相同。

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>

【问题讨论】:

    标签: android angular ionic-framework ionic2 ionic-view


    【解决方案1】:

    这是最近 ionic 和 A2 的常见问题,解决了 main.prod.*Try 更新项目的应用脚本。

    npm install @ionic/app-scripts@latest
    

    您的错误消息应该会随着实际导致您的构建崩溃的原因而改变。如果错误消息发生变化,请使用新消息更新您的问题。

    也可以查看此链接以获取有关此问题的更多信息:Ionic forum

    【讨论】:

    • 好的,你在运行 npm 3.x 吗?
    • 是的,如果这只是您正在运行的示例,请尝试完全删除该项目并运行一个新项目。 node_modules 中可能有问题。
    【解决方案2】:

    关闭所有离子文件夹和服务或实验室。然后再试一次,ionic cordova build android。

    【讨论】:

      【解决方案3】:

      首先,检查 package.json 文件中的 Android 版本。

      现在用这个命令删除平台(ionic cordova platform rm android)

      然后使用此命令添加平台(ionic cordova platform add

      android@6.4.0)。如果 7.0.0 版本不稳定,请使用 6.4.0

      现在,运行此命令(ionic cordova run android)或在 mac 中(sudo ionic cordova run android)

      【讨论】:

        【解决方案4】:

        试试下面的命令

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

        【讨论】:

          【解决方案5】:

          您的系统中存在路径设置问题。

          第一次使用 CMD 检查 npm 版本:npm -v

          如果显示版本号,则使用下面的代码,否则首先设置你的 npm 路径,你可以使用 gitbash cmd,nodejs cmd

          尝试使用

          ionic cordova run android 
          

          或

          ionic cordova platform remove android
          
          ionic cordova run android
          

          如果你有 MAC 系统必须使用 sudo 之类的

          sudo ionic cordova run android
          

          【讨论】:

            猜你喜欢
            • 1970-01-01
            • 1970-01-01
            • 2017-01-01
            • 2023-03-22
            • 2014-11-16
            • 1970-01-01
            • 1970-01-01
            • 2015-08-01
            • 2023-03-20
            相关资源
            最近更新 更多