Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/shell/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Macos 如果我使用npm启动webpack服务,如何杀死它?(ps aux | grep网页每次都不同)_Macos_Shell_Webpack_Service_Process - Fatal编程技术网

Macos 如果我使用npm启动webpack服务,如何杀死它?(ps aux | grep网页每次都不同)

Macos 如果我使用npm启动webpack服务,如何杀死它?(ps aux | grep网页每次都不同),macos,shell,webpack,service,process,Macos,Shell,Webpack,Service,Process,在lib/assets目录中,我运行了npm install,该目录中的package.json文件具有以下内容: "scripts": { "test": blah "bundle": "./node_modules/.bin/webpack", "lint": blah }, 因此,我可以通过调用npm run bundle或npm run bundle--p 我怎么杀它 注意:ps aux | grep网页每次提供不同的pid: USER

lib/assets
目录中,我运行了
npm install
,该目录中的
package.json
文件具有以下内容:

  "scripts": {
    "test": blah
    "bundle": "./node_modules/.bin/webpack",
    "lint": blah
  },
因此,我可以通过调用
npm run bundle
npm run bundle--p

我怎么杀它

注意
ps aux | grep网页
每次提供不同的pid:

USER               PID  COMMAND

my-name         85294  grep --color=auto --exclude-dir=.bzr --exclude-dir=CVS --exclude-dir=.git --exclude-dir=.hg --exclude-dir=.svn webapck

my-name         85305  grep --color=auto --exclude-dir=.bzr --exclude-dir=CVS --exclude-dir=.git --exclude-dir=.hg --exclude-dir=.svn webapck

my-name         85316  grep --color=auto --exclude-dir=.bzr --exclude-dir=CVS --exclude-dir=.git --exclude-dir=.hg --exclude-dir=.svn webapck

类似这样的东西在bash中也可以使用:

$ ps -ef | grep webpack | awk '{print $2}' | xargs kill

原来我误解了网页包的工作原理

我想Webpack会继续在后台运行,并为我编译资产

为了解释我为什么会这样想,让我从一开始:

我从GitHub()派生了一个rails项目,让它启动并运行,但我意识到,当我通过浏览器访问rails应用程序网站时,它不会显示图像,并且它的布局也不会被应用(样式表)。我意识到我需要使用webpack来编译这些资产

因此,我通过运行
npm install
npm run bundle
启动了webpack,终端显示如下内容:

$ npm run bundle

> roadmap@1.0.0 bundle /Users/my-name/dev/testing/dmp-roadmap/lib/assets
> webpack


Webpack is watching the files…

Hash: 1af8780dadb3d5abe275
Version: webpack 3.11.0
Time: 7360ms
                                                 Asset       Size  Chunks                    Chunk Names
                           images/bournemouth_logo.png    16.1 kB          [emitted]
                fonts/glyphicons-halflings-regular.eot    20.1 kB          [emitted]
               fonts/glyphicons-halflings-regular.woff    23.4 kB          [emitted]
                fonts/glyphicons-halflings-regular.ttf    45.4 kB          [emitted]
                fonts/glyphicons-halflings-regular.svg     109 kB          [emitted]
                         fonts/fontawesome-webfont.eot     166 kB          [emitted]
                       fonts/fontawesome-webfont.woff2    77.2 kB          [emitted]
                        fonts/fontawesome-webfont.woff      98 kB          [emitted]
                         fonts/fontawesome-webfont.ttf     166 kB          [emitted]
                         fonts/fontawesome-webfont.svg     444 kB          [emitted]  [big]
  ./stylesheets/skins/lightgray/content.inline.min.css    3.17 kB          [emitted]
         ./stylesheets/skins/lightgray/content.min.css    3.57 kB          [emitted]
 ./stylesheets/skins/lightgray/fonts/tinymce-small.eot    9.49 kB          [emitted]
 ./stylesheets/skins/lightgray/fonts/tinymce-small.svg    24.7 kB          [emitted]
 ./stylesheets/skins/lightgray/fonts/tinymce-small.ttf     9.3 kB          [emitted]
./stylesheets/skins/lightgray/fonts/tinymce-small.woff    9.38 kB          [emitted]
       ./stylesheets/skins/lightgray/fonts/tinymce.eot    17.6 kB          [emitted]
       ./stylesheets/skins/lightgray/fonts/tinymce.svg      46 kB          [emitted]
       ./stylesheets/skins/lightgray/fonts/tinymce.ttf    17.4 kB          [emitted]
      ./stylesheets/skins/lightgray/fonts/tinymce.woff    17.5 kB          [emitted]
          ./stylesheets/skins/lightgray/img/anchor.gif   53 bytes          [emitted]
          ./stylesheets/skins/lightgray/img/loader.gif    2.61 kB          [emitted]
          ./stylesheets/skins/lightgray/img/object.gif  152 bytes          [emitted]
           ./stylesheets/skins/lightgray/img/trans.gif   43 bytes          [emitted]
            ./stylesheets/skins/lightgray/skin.min.css      40 kB          [emitted]
                            javascripts/application.js    3.26 MB       0  [emitted]  [big]  application
                                 javascripts/vendor.js     317 kB       1  [emitted]  [big]  vendor
                           stylesheets/application.css     201 kB       0  [emitted]         application
                       images/2013_Jisc_Logo_RGB72.png    2.12 kB          [emitted]
                                        images/asc.gif   54 bytes          [emitted]
                                 images/background.jpg    1.69 kB          [emitted]
                                         images/bg.gif   64 bytes          [emitted]
                             images/dcc_logo_white.png    3.03 kB          [emitted]
                                   images/dcc_logo.png  907 bytes          [emitted]
              fonts/glyphicons-halflings-regular.woff2      18 kB          [emitted]
                                       images/desc.gif   54 bytes          [emitted]
                                   images/download.png    2.55 kB          [emitted]
                                 images/fullscreen.png  341 bytes          [emitted]
                                    images/favicon.ico    1.15 kB          [emitted]
                 images/glyphicons-halflings-white.png    8.78 kB          [emitted]
                                images/help_button.png  557 bytes          [emitted]
                       images/glyphicons-halflings.png    12.8 kB          [emitted]
                                       images/logo.png    15.5 kB          [emitted]
                              images/minus_laranja.png  408 bytes          [emitted]
                             images/lancaster_logo.png    26.2 kB          [emitted]
                           images/lse-library_logo.png    18.2 kB          [emitted]
                               images/plus_laranja.png  781 bytes          [emitted]
                              images/question-mark.png    2.57 kB          [emitted]
                                      images/rails.png    6.65 kB          [emitted]
                             images/newcastle_logo.png     142 kB          [emitted]
                                     images/remove.png  681 bytes          [emitted]
                   images/roadmap_logo_orange_grey.png    3.81 kB          [emitted]
                  images/roadmap_logo_orange_white.png    3.56 kB          [emitted]
                               images/salford_logo.png    8.36 kB          [emitted]
                            images/select2-spinner.gif    1.85 kB          [emitted]
                                    images/select2.png  613 bytes          [emitted]
                                  images/select2x2.png  845 bytes          [emitted]
                             images/uc3_logo_white.png    3.11 kB          [emitted]
                                 images/screencast.jpg     103 kB          [emitted]
                                   images/uc3_logo.jpg       4 kB          [emitted]
                                    images/ue_logo.png    26.9 kB          [emitted]
          videos/index.files/html5video/fullscreen.png  341 bytes          [emitted]
            videos/index.files/html5video/flashfox.swf     4.9 kB          [emitted]
             videos/index.files/html5video/html5ext.js    3.51 kB          [emitted]
          videos/index.files/html5video/screencast.jpg     103 kB          [emitted]
          videos/index.files/html5video/screencast.mp4    12.3 MB          [emitted]  [big]
         videos/index.files/html5video/screencast.webm    13.7 MB          [emitted]  [big]
          videos/index.files/html5video/screencast.m4v    13.8 MB          [emitted]  [big]
          videos/index.files/html5video/screencast.ogv    24.7 MB          [emitted]  [big]
  [15] ./javascripts/utils/links.js 4.71 kB {0} [built]
  [18] ./javascripts/utils/paginable.js 1.09 kB {0} [built]
  [27] ./javascripts/views/org_admin/questions/sharedEventHandlers.js 1.3 kB {0} [built]
  [28] ./javascripts/views/org_admin/question_options/index.js 1.52 kB {0} [built]
 [156] multi jquery timeago.js jquery-accessible-autocomplete-list-aria/jquery-accessible-autocomplete-list-aria jquery-ujs 64 bytes {1} [built]
 [159] multi ./javascripts/application.js ./stylesheets/application.scss 40 bytes {0} [built]
 [160] ./javascripts/application.js 1.77 kB {0} [built]
 [236] ./javascripts/views/shared/sign_in_form.js 1.81 kB {0} [built]
 [238] ./javascripts/views/super_admin/themes/new_edit.js 424 bytes {0} [built]
 [239] ./javascripts/views/super_admin/users/edit.js 485 bytes {0} [built]
 [240] ./javascripts/views/usage/index.js 7.67 kB {0} [built]
 [289] ./javascripts/views/users/notification_preferences.js 622 bytes {0} [built]
 [290] ./javascripts/views/users/admin_grant_permissions.js 4.43 kB {0} [built]
 [291] ./javascripts/views/super_admin/notifications/edit.js 509 bytes {0} [built]
 [292] ./stylesheets/application.scss 41 bytes {0} [built]
    + 291 hidden modules
Child extract-text-webpack-plugin node_modules/extract-text-webpack-plugin/dist node_modules/css-loader/index.js!node_modules/sass-loader/lib/loader.js!stylesheets/application.scss:
     10 assets
       [1] ./node_modules/css-loader!./node_modules/sass-loader/lib/loader.js!./stylesheets/application.scss 214 kB {0} [built]
        + 13 hidden modules
由于运行
npm run bundle
不会显示终端新行提示(我指的是
$
字符),我认为它就像一个服务器,不断地为我的rails应用程序提供资产文件

我刷新了网站,它显示了美丽的图像和布局

我按CTRL+C停止网页,然后再次重新加载网站,它仍然美丽地显示图像和布局,我错误地得出结论,该网页现在正在后台为文件服务

但我错了

在我按CTRL+C停止webpack进程后,webpack停止了文件服务。但是,因为它以前已经编译了资产文件并将它们存储在我的项目目录中的公共目录中,所以我的网站只使用其中的文件。这就是为什么该网站仍然能漂亮地展示图片和布局的真正原因

因此,要停止
npm run bundle
,就我而言,这与调用
webpack
相同,我只需按CTRL+C即可

对于
npm run bundle--p
,我不知道它现在在做什么,在运行它之后(考虑到我已经运行了npm run bundle并使用CTRL+C停止它),网站停止正确显示图像和布局


另外,当我调用
ps aux | grep webpack
时,我看到PID不断变化的原因是
grep
是我看到的进程,每次我启动
grep
时,它将是一个新的不同进程,因此它将具有不同的PID。当我按下CTRL+C时,webpack进程已经停止。

CTRL+C不会终止它吗?