【问题标题】:ionic serve fails for Ionic 2 rc0 applicationIonic 2 rc0 应用程序的 ionic serve 失败
【发布时间】:2017-06-26 04:13:53
【问题描述】:

我刚刚创建了一个新的 Ionic 2 rc0 应用程序,并且昨晚能够运行它。

但是,在运行 ionic serve 时让计算机进入睡眠状态后,今天尝试在关闭 ionic serve 后启动应用程序会产生此错误:

Running 'serve:before' npm script before serve
> ionic-hello-world@ watch J:\ionic projects\newionicapp
> ionic-app-scripts watch
module.js:457
    throw err;
    ^

Error: Cannot find module '../dist/index'
    at Function.Module._resolveFilename (module.js:455:15)
    at Function.Module._load (module.js:403:25)
    at Module.require (module.js:483:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (J:\ionic projects\newionicapp\node_modules\@ionic\app-scripts\bin\ionic-app-scripts.js:19:3)
    at Module._compile (module.js:556:32)
    at Object.Module._extensions..js (module.js:565:10)
    at Module.load (module.js:473:32)
    at tryModuleLoad (module.js:432:12)
    at Function.Module._load (module.js:424:3)



npm
 ERR! Windows_NT 10.0.10586
npm ERR! argv "J:\\Program Files (x86)\\nodejs\\node.exe" "C:\\Users\\rosst\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js" "run" "watch"
npm ERR! node v6.7.0
npm ERR! npm  v3.10.8
npm ERR! code ELIFECYCLE
npm ERR! ionic-hello-world@ watch: `ionic-app-scripts watch`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the ionic-hello-world@ watch script 'ionic-app-scripts watch'.
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 watch
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!     J:\rosst\ionic projects\newionicapp\npm-debug.log

Caught exception:
 undefined

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

如果我创建一个新应用程序,它运行良好。所以我认为我的项目内部出了问题。但我不知道是什么。

【问题讨论】:

  • 不知道为什么有人对这个问题投了反对票,所以应该有一些选项可以在投反对票时添加评论。 :)。因为这在离题下被否决了,但这个问题对我来说似乎是合法的
  • 您也可以尝试删除整个node-modules 文件夹,然后再次运行npm install...
  • @sebaferreras 这对我有用,包括删除 .tmp 文件夹。

标签: angular ionic-framework ionic2


【解决方案1】:

删除您的 node_modules 文件夹,然后运行 ​​npm install 以重新安装所有模块。这将确保所有节点模块都是干净的。

同时删除 www 文件夹的内容,然后运行 ​​ionic serve 重新生成文件。这将确保您的项目构建是干净的。

如果这不起作用,请尝试通过运行 npm install -g ionic@2.1.0 将您的 ionic-cli 更新到最新版本,然后再次尝试上述操作。

Ionic CLI 使用的 ionic-app-scripts 版本不是特定的目标版本。 Ionic-app-scripts 已更新,虽然 ionic-cli 没有,但它现在使用更新版本的 ionic-app-scripts,这给我带来了一些问题。

祝你好运!

【讨论】:

  • 您的答案也适用于 Ionic 4。删除 www 文件夹解决了问题。
【解决方案2】:

尝试更新 ionic 应用脚本。

npm i @ionic/app-scripts

它对我有用。

【讨论】:

    【解决方案3】:

    我遇到了同样的问题,我研究了很多并找到了一个解决方案,在你的终端上尝试这个命令 -

    echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p
    

    【讨论】:

      【解决方案4】:

      我发现error 有点相似,它看起来与更新 npm 有关。

      所以尝试将 npm 更新到最新版本。 read here 升级步骤。

      PS:但这并不能解释为什么它适用于新项目。 :)

      【讨论】:

        【解决方案5】:

        我对此有很多问题。 我在互联网上搜索并尝试了所有可能的解决方案,但没有运气。

        我终于发现,从应用名称中删除空格可以让一切正常。所以删除包含所有内容的 det app 文件夹,并创建一个名称中没有空格的新文件夹。

        无论如何,这对我有用。

        【讨论】:

        • 看来问题不是多余的空格
        猜你喜欢
        • 2022-07-15
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2018-02-22
        • 2017-06-04
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多