【问题标题】:Ionic Cordova CLI failures on build ios command - "Module not found, can't resolve..."构建 ios 命令时 Ionic Cordova CLI 失败 - “未找到模块,无法解析...”
【发布时间】:2017-10-29 05:10:30
【问题描述】:

我正在尝试运行 ionic cordova build ios 并且一直遇到以下问题:

Error: ./src/app/app.module.ts
Module not found: Error: Can't resolve '@ionic-native/file' in '/Users/justinfrevert/Desktop/AceAdz-App/app-copy/src/app'
resolve '@ionic-native/file' in '/Users/justinfrevert/Desktop/AceAdz-App/app-copy/src/app'
  Parsed request is a module
  using description file: /Users/justinfrevert/Desktop/AceAdz-App/app-copy/package.json (relative path: ./src/app)
    Field 'browser' doesn't contain a valid alias configuration
  after using description file: /Users/justinfrevert/Desktop/AceAdz-App/app-copy/package.json (relative path: ./src/app)
    resolve as module
      looking for modules in /Users/justinfrevert/Desktop/AceAdz-App/app-copy/node_modules
        using description file: /Users/justinfrevert/Desktop/AceAdz-App/app-copy/package.json (relative path: ./node_modules)
          Field 'browser' doesn't contain a valid alias configuration
        after using description file: /Users/justinfrevert/Desktop/AceAdz-App/app-copy/package.json (relative path: ./node_modules)
          using description file: /Users/justinfrevert/Desktop/AceAdz-App/app-copy/package.json (relative path: ./node_modules/@ionic-native/file)
            no extension
              Field 'browser' doesn't contain a valid alias configuration
              /Users/justinfrevert/Desktop/AceAdz-App/app-copy/node_modules/@ionic-native/file doesn't exist
            .ts
              Field 'browser' doesn't contain a valid alias configuration
              /Users/justinfrevert/Desktop/AceAdz-App/app-copy/node_modules/@ionic-native/file.ts doesn't exist
            .js
              Field 'browser' doesn't contain a valid alias configuration
              /Users/justinfrevert/Desktop/AceAdz-App/app-copy/node_modules/@ionic-native/file.js doesn't exist
            .json
              Field 'browser' doesn't contain a valid alias configuration
              /Users/justinfrevert/Desktop/AceAdz-App/app-copy/node_modules/@ionic-native/file.json doesn't exist
            as directory
              /Users/justinfrevert/Desktop/AceAdz-App/app-copy/node_modules/@ionic-native/file doesn't exist
[/Users/justinfrevert/Desktop/AceAdz-App/app-copy/node_modules/@ionic-native/file]
[/Users/justinfrevert/Desktop/AceAdz-App/app-copy/node_modules/@ionic-native/file.ts]
[/Users/justinfrevert/Desktop/AceAdz-App/app-copy/node_modules/@ionic-native/file.js]
[/Users/justinfrevert/Desktop/AceAdz-App/app-copy/node_modules/@ionic-native/file.json]
[/Users/justinfrevert/Desktop/AceAdz-App/app-copy/node_modules/@ionic-native/file]
 @ ./src/app/app.module.ts 23:0-42
 @ ./src/app/main.ts,./src/app/app.module.ts
Module not found: Error: Can't resolve '@ionic-native/photo-library' in '/Users/justinfrevert/Desktop/AceAdz-App/app-copy/src/app'
resolve '@ionic-native/photo-library' in '/Users/justinfrevert/Desktop/AceAdz-App/app-copy/src/app'
  Parsed request is a module
  using description file: /Users/justinfrevert/Desktop/AceAdz-App/app-copy/package.json (relative path: ./src/app)
    Field 'browser' doesn't contain a valid alias configuration
  after using description file: /Users/justinfrevert/Desktop/AceAdz-App/app-copy/package.json (relative path: ./src/app)
    resolve as module
      looking for modules in /Users/justinfrevert/Desktop/AceAdz-App/app-copy/node_modules
        using description file: /Users/justinfrevert/Desktop/AceAdz-App/app-copy/package.json (relative path: ./node_modules)
          Field 'browser' doesn't contain a valid alias configuration
        after using description file: /Users/justinfrevert/Desktop/AceAdz-App/app-copy/package.json (relative path: ./node_modules)
          using description file: /Users/justinfrevert/Desktop/AceAdz-App/app-copy/package.json (relative path: ./node_modules/@ionic-native/photo-library)
            no extension
              Field 'browser' doesn't contain a valid alias configuration
              /Users/justinfrevert/Desktop/AceAdz-App/app-copy/node_modules/@ionic-native/photo-library doesn't exist
            .ts
              Field 'browser' doesn't contain a valid alias configuration
              /Users/justinfrevert/Desktop/AceAdz-App/app-copy/node_modules/@ionic-native/photo-library.ts doesn't exist
            .js
              Field 'browser' doesn't contain a valid alias configuration
              /Users/justinfrevert/Desktop/AceAdz-App/app-copy/node_modules/@ionic-native/photo-library.js doesn't exist
            .json
              Field 'browser' doesn't contain a valid alias configuration
              /Users/justinfrevert/Desktop/AceAdz-App/app-copy/node_modules/@ionic-native/photo-library.json doesn't exist
            as directory
              /Users/justinfrevert/Desktop/AceAdz-App/app-copy/node_modules/@ionic-native/photo-library doesn't exist
[/Users/justinfrevert/Desktop/AceAdz-App/app-copy/node_modules/@ionic-native/photo-library]
[/Users/justinfrevert/Desktop/AceAdz-App/app-copy/node_modules/@ionic-native/photo-library.ts]
[/Users/justinfrevert/Desktop/AceAdz-App/app-copy/node_modules/@ionic-native/photo-library.js]
[/Users/justinfrevert/Desktop/AceAdz-App/app-copy/node_modules/@ionic-native/photo-library.json]
[/Users/justinfrevert/Desktop/AceAdz-App/app-copy/node_modules/@ionic-native/photo-library]
 @ ./src/app/app.module.ts 28:0-59
 @ ./src/app/main.ts
    at new BuildError (/Users/justinfrevert/Desktop/AceAdz-App/app-copy/node_modules/@ionic/app-scripts/dist/util/errors.js:16:28)
    at callback (/Users/justinfrevert/Desktop/AceAdz-App/app-copy/node_modules/@ionic/app-scripts/dist/webpack.js:121:28)
    at emitRecords.err (/Users/justinfrevert/Desktop/AceAdz-App/app-copy/node_modules/webpack/lib/Compiler.js:269:13)
    at Compiler.emitRecords (/Users/justinfrevert/Desktop/AceAdz-App/app-copy/node_modules/webpack/lib/Compiler.js:375:38)
    at emitAssets.err (/Users/justinfrevert/Desktop/AceAdz-App/app-copy/node_modules/webpack/lib/Compiler.js:262:10)
    at applyPluginsAsyncSeries1.err (/Users/justinfrevert/Desktop/AceAdz-App/app-copy/node_modules/webpack/lib/Compiler.js:368:12)
    at next (/Users/justinfrevert/Desktop/AceAdz-App/app-copy/node_modules/tapable/lib/Tapable.js:218:11)
    at Compiler.compiler.plugin (/Users/justinfrevert/Desktop/AceAdz-App/app-copy/node_modules/webpack/lib/performance/SizeLimitsPlugin.js:99:4)
    at Compiler.applyPluginsAsyncSeries1 (/Users/justinfrevert/Desktop/AceAdz-App/app-copy/node_modules/tapable/lib/Tapable.js:222:13)
    at Compiler.afterEmit (/Users/justinfrevert/Desktop/AceAdz-App/app-copy/node_modules/webpack/lib/Compiler.js:365:9)

代码更改后没有发生这种情况。这在我试图纠正一个单独的错误之后开始发生:编译器抱怨不正确的类型从离子原生地理定位传递到 watchPosition() 方法。这是一个单独的问题,也是由版本更改引起的 - 所以我尝试将版本从最新版本恢复到 3.14.0。这就是导致上述错误的原因。然后我恢复到 3.11.0,因为那是我在它工作时使用的原始版本。我尝试构建,但仍然无法正常工作。然后我切换回最新版本,但仍然出现上述错误。我尝试卸载并重新安装用于地理定位的cordova和npm包,仍然没有骰子。请让我知道我可以做些什么来解决这个问题。

【问题讨论】:

    标签: node.js cordova ionic-framework npm


    【解决方案1】:

    现在您拥有最新版本,因此请确保您已安装所有最新的 cordova 和 npm 软件包。在此之后,请删除 ios 平台,然后再次添加它。此外,请确保您的 config.xml 中有所有您感兴趣的平台的引擎条目。这可以保证您使用的是您在本地使用的确切平台工具版本。我认为config.xml中指定的平台工具版本与项目不兼容,需要升级或降级的实例。

    【讨论】:

    • 我尝试重新添加平台并遇到了这个问题:错误:找不到插件“平台”的 plugin.xml。请尝试重新添加。我检查了插件,没有名为“平台”的插件。我用谷歌搜索了这个,找不到任何有用的东西。我想我可能会为这个问题写一篇新文章。
    猜你喜欢
    • 2018-06-07
    • 1970-01-01
    • 2019-07-28
    • 1970-01-01
    • 2022-11-01
    • 2020-02-25
    • 1970-01-01
    • 1970-01-01
    • 2019-02-05
    相关资源
    最近更新 更多