{"id":199345,"date":"2020-11-10T01:12:17","date_gmt":"2020-11-09T17:12:17","guid":{"rendered":"http:\/\/4563.org\/?p=199345"},"modified":"2020-11-10T01:12:17","modified_gmt":"2020-11-09T17:12:17","slug":"rails-new-%e5%91%bd%e4%bb%a4%e4%b8%80%e7%9b%b4%e8%bd%ac%e5%9c%88%e6%80%8e%e4%b9%88%e5%8a%9e%ef%bc%9f","status":"publish","type":"post","link":"http:\/\/4563.org\/?p=199345","title":{"rendered":"Rails new \u547d\u4ee4\u4e00\u76f4\u8f6c\u5708\u600e\u4e48\u529e\uff1f"},"content":{"rendered":"<div>\n<div>\n<div>\n<h1>                  Rails new \u547d\u4ee4\u4e00\u76f4\u8f6c\u5708\u600e\u4e48\u529e\uff1f               <\/h1>\n<p> <\/p>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : coool <\/span>  <span><i><\/i> 6<\/span> <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<\/p><\/div>\n<div isfirst=\"1\"> <\/p>\n<p>\u5927\u4f6c\u4eec\uff0c\u6267\u884c<code>rails new demo<\/code>\u547d\u4ee4\u65f6\u5230\u4e0b\u9762\u8fd9\u91cc\u4e00\u76f4\u5728\u8f6c\u5708\uff0c\u5f88\u4e45\u4e5f\u4e0d\u5f80\u4e0b\u8d70\uff0c\u6c42\u6307\u70b9\uff1a<\/p>\n<pre><code>warning @rails\/webpacker &gt; webpack &gt; watchpack &gt; watchpack-chokidar2 &gt; [email&#160;protected]: Chokidar 2 will break on node v14+. Upgrade to chokidar 3 with 15x less dependencies. warning @rails\/webpacker &gt; webpack &gt; watchpack &gt; watchpack-chokidar2 &gt; chokidar &gt; [email&#160;protected]: fsevents 1 will break on node v14+ and could be using insecure binaries. Upgrade to fsevents 2. warning @rails\/webpacker &gt; webpack &gt; micromatch &gt; snapdragon &gt; source-map-resolve &gt; [email&#160;protected]: https:\/\/github.com\/lydell\/resolve-url#deprecated warning @rails\/webpacker &gt; webpack &gt; micromatch &gt; snapdragon &gt; source-map-resolve &gt; [email&#160;protected]: Please see https:\/\/github.com\/lydell\/urix#deprecated [2\/4]       <\/div>\n<div> <b>\u5927\u4f6c\u6709\u8a71\u8aaa<\/b> (<span>19<\/span>)        <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<ul>\n<li data-pid=\"4114927\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : qiuyi116 <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u6211\u8bb0\u5f97\u662f\u6709 node \u4f9d\u8d56\u3002npm \u4e5f\u52a0\u4e00\u6b21\u955c\u50cf\u3002                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"4114928\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : coool <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @qiuyi116 \u521a\u8bbe\u7f6e\u4e86 `npm config set registry https:\/\/registry.npm.taobao.org`\uff0c \u73b0\u5728\u8fd8\u5728\u8f6c\u5708\u4e2d\u2026\u2026\u53e6\u5916\u4e0a\u9762\u5f88\u591a warning \u600e\u4e48\u5904\u7406\u6389\uff1f`webpacker`\u5df2\u7ecf\u66f4\u65b0\u5230 5.2.1 \u4e86                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"4114929\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : coool <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u5f04\u4e00\u5929\u4e86\u90fd\u6ca1\u5f04\u597d\uff0c\u53ef\u80fd\u662f rails \u95e8\u69db\u592a\u9ad8\uff0c\u9ad8\u6500\u4e0d\u8d77\u2026\u2026                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"4114930\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : aristolochic <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             node-sass \u662f\u6709\u4e8c\u8fdb\u5236\u4f9d\u8d56\uff08 node-gyp \uff09\u7684\uff0c\u6dd8\u5b9d\u6709\u9884\u7f16\u8bd1\u7684\u4e8c\u8fdb\u5236\u5305\uff0c\u4f46\u662f\u8981\u60f3\u76f4\u63a5\u4f7f\u7528\u53ef\u4e0d\u662f\u8bbe\u7f6e npm \u7684\u955c\u50cf\u6e90\u5c31\u5b8c\u4e8b\u513f\u4e86\u7684\uff0c\u5177\u4f53\u770b taobao npm \u7684\u6587\u6863\u3002\u4e0a\u9762\u7684 warning \u5ffd\u7565\u5c31\u884c\uff0c\u90fd\u90a3\u6837\u3002                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"4114931\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : fangxing204 <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u5e94\u8be5\u662f\u5361\u5728 yarn install \u4e86\uff0c\u8bd5\u8bd5\u8bbe\u7f6e\u4ee3\u7406\uff0c\u5220\u6389 node_modules \u91cd\u8bd5\uff1f                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"4114932\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : doublechenpaul <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @coool \u9996\u5148\u4e0d\u540c\u610f\u4f60\u8bf4\u7684\u95e8\u69db\u592a\u9ad8\uff0c\u7b2c\u4e8c\uff0c\u53ef\u4ee5\u8d34\u4e00\u4e0b rails \u7248\u672c\u53ca ruby \u7248\u672c\u5417                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"4114933\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : coool <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @fangxing204 \u521a\u8bbe\u7f6e\u4e86 `yarn config set sass_binary_site http:\/\/cdn.npm.taobao.org\/dist\/node-sass -g`, `yarn config set registry https:\/\/registry.npm.taobao.org` \u8fd8\u662f\u4e0d\u884c\uff0c\u7ffb\u5899\u4e5f\u4e0d\u884c\u2026\u2026<\/p>\n<p>@aristolochic \u6267\u884c\u4e86 <\/p>\n<p>```<br \/>echo 'n#alias for cnpmnalias cnpm=\"npm --registry=https:\/\/registry.npm.taobao.org <br \/> --cache=$HOME\/.npm\/.cache\/cnpm <br \/> --disturl=https:\/\/npm.taobao.org\/dist <br \/> --userconfig=$HOME\/.cnpmrc\"' &gt;&gt; ~\/.zshrc &amp;&amp; source ~\/.zshrc<br \/>```<br \/>\u4e5f\u4e0d\u884c\u3002                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"4114934\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : coool <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @doublechenpaul \u5927\u4f6c\uff0cruby \u7248\u672c\uff1a`ruby 2.7.2p137 (2020-10-01 revision 5445e04352) [x86_64-darwin19]`, rails \u7248\u672c\uff1a\u00b7Rails 6.0.3.4`\u3002\u6309\u7167\u8fd9\u4e2a\u64cd\u4f5c\u4e86\u5df2\u7ecf\uff1a https:\/\/ruby-china.org\/wiki\/install_ruby_guide                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"4114935\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : doublechenpaul <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @doublechenpaul \u5750\u6807\u5e7f\u5dde\uff0c\u4e09\u4e2a\u5708\u5708\u8f6c\u4e86 10 \u5206\u949f\u5de6\u53f3\u5c31\u5b89\u88c5\u6210\u529f\u4e86                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"4114936\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : impl <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             Ctrl C \u8bd5\u8bd5\uff1f                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"4114937\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : coool <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @doublechenpaul \u5927\u4f6c\uff0c\u5565\u8bbe\u7f6e\uff1f\u6211\u8fd9\u4ece\u4e5d\u70b9\u534a\u4e0a\u73ed\u8f6c\u5230\u73b0\u5728\u4e86\u3002<\/p>\n<p>@impl Ctrl C =&gt; rm -rf demo =&gt; rails new demo\uff0c \u5f88\u591a\u6b21\u4e86                                                            <\/p><\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"4114938\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : coool <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u54c7\uff0c\u5220\u9664\u4e86\u6240\u6709\u7684\u4ee3\u7406\uff0c\u672c\u5730 global \u7ffb\u5899\uff0c\u7ec8\u4e8e\u6210\u529f\u4e86\u2026\u2026                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"4114939\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : msg7086 <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u4f60\u5982\u679c\u53ea\u662f\u8981 new \u4e00\u4e2a\u65b0\u7684 Rails \u9879\u76ee\u7684\u8bdd\uff0c\u5982\u679c\u7528\u4e0d\u5230 webpack \u90a3\u53ef\u4ee5\u8df3\u8fc7 webpack \u90a3\u5757\u3002                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"4114940\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : coool <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @msg7086 \u5509\uff0c\u73b0\u5728\u53c8\u78b0\u5230\u65b0\u95ee\u9898\u4e86\uff0c\u6211\u6267\u884c`bin\/rails generate controller Say hello goodbye`\u4e4b\u540e\u8bbf\u95ee`localhost:3000\/say\/hello`\u4e00\u76f4\u62a5\uff1a <\/p>\n<p>```<br \/>[Webpacker] Compiling...<br \/>[Webpacker] Compilation failed:<br \/>yarn run v1.22.10<br \/>info Visit https:\/\/yarnpkg.com\/en\/docs\/cli\/run for documentation about this command.<\/p>\n<p>error Command \"webpack\" not found.<br \/>```<\/p>\n<p>\u6267\u884c\u5565\u90fd\u6ca1\u7528\uff0c` bundle exec rails webpacker:install`\u4e5f\u4e0d\u884c\u2026\u2026<\/p>\n<p>\u6101\u4eba                                                            <\/p><\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"4114941\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : msg7086 <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u6211\u4e0d\u7528 webpack \u7684\uff0c\u5e2e\u4e0d\u4e86\u4f60\u2026\u2026                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"4114942\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : doublechenpaul <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @coool https:\/\/stackoverflow.com\/questions\/44845143\/webpack-command-not-found<br \/>\u4f60\u8bd5\u8bd5\u8fd9\u4e2a\uff0c\u611f\u89c9\u662f\u56e0\u4e3a\u4f60\u672c\u5730\u6267\u884c\u8def\u5f84\u6709\u95ee\u9898                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"4114943\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : wangkun025 <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u7528 rails5                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"4114944\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : wangkun025 <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             gem install rails -v 5.2.4.4<br \/>rails _5.2.4.4_ new demo<br \/>cd demo<br \/>rails g scaffold Post title:string<br \/>rake db:migrate<\/p>\n<p>visit http:\/\/localhost:3000\/posts<\/p>\n<p>\u4e0a\u9762\u7684\u6211\u6d4b\u8bd5\u4e86\uff0c\u6ca1\u95ee\u9898\u3002                                                            <\/p><\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"4114945\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : lidashuang <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u76ee\u6d4b npm \u7684\u9505                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li>\n","protected":false},"excerpt":{"rendered":"<p>Rails new \u547d\u4ee4\u4e00\u76f4\u8f6c\u5708\u600e&hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[],"tags":[],"_links":{"self":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/199345"}],"collection":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=199345"}],"version-history":[{"count":0,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/199345\/revisions"}],"wp:attachment":[{"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=199345"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=199345"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=199345"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}