错误:找不到模块@ ionic / cli-utils

时间:2017-06-02 18:56:57

标签: ionic-framework npm

我试图在终端中运行离子并遇到以下错误:

module.js:487
    throw err;
    ^

Error: Cannot find module '@ionic/cli-utils'
    at Function.Module._resolveFilename (module.js:485:15)
    at Function.Module._load (module.js:437:25)
    at Module.require (module.js:513:17)
    at require (internal/module.js:11:18)
    at Object.<anonymous> (/usr/local/lib/node_modules/ionic/dist/index.js:14:21)
    at Module._compile (module.js:569:30)
    at Object.Module._extensions..js (module.js:580:10)
    at Module.load (module.js:503:32)
    at tryModuleLoad (module.js:466:12)
    at Function.Module._load (module.js:458:3)

我在谷歌上环顾四周但却找不到任何错误原因。有什么想法吗?

3 个答案:

答案 0 :(得分:3)

更新新版本时也发生在我身上。解决它:

  1. 删除 node_modules
  2. 删除 package-lock.json 文件
  3. 运行 npm install 命令
  4. ionic serve

答案 1 :(得分:2)

在将Ionic更新为最新版本(目前为3.9.2)时发生了。 解决了它做到以下几点:

  • 删除package-lock.json文件
  • 删除node_modules/文件夹
  • package.json个文件依赖项和devDependencies部分编辑为:

    "dependencies": {
        "@angular/common": "4.1.3",
        "@angular/compiler": "4.1.3",
        "@angular/compiler-cli": "4.1.3",
        "@angular/core": "4.1.3",
        "@angular/forms": "4.1.3",
        "@angular/http": "4.1.3",
        "@angular/platform-browser": "4.1.3",
        "@angular/platform-browser-dynamic": "4.1.3",
        "@ionic-native/core": "3.12.1",
        "@ionic-native/splash-screen": "3.12.1",
        "@ionic-native/status-bar": "3.12.1",
        "@ionic/storage": "2.0.1",
        "ionic-angular": "3.6.0",
        "ionicons": "3.0.0",
        "rxjs": "5.4.0",
        "sw-toolbox": "3.6.0",
        "zone.js": "0.8.12"      
    },
    "devDependencies": {
        "@ionic/app-scripts": "2.1.3",
        "typescript": "2.3.4"
    }
    
  • 再次运行npm install
  • 编辑www/index.html文件中的脚本部分:

    <script src="build/polyfills.js"></script>
    <script src="build/vendor.js"></script>
    <script src="build/main.js"></script>
    

答案 2 :(得分:0)

你的离子版是什么?请输入一些离子信息 如果是ionic3.x 试试npm i -g @ ionic / cli-utils? 我解决了,