npm开始无法在React项目中工作

时间:2018-07-18 05:34:56

标签: node.js reactjs npm

我目前正在从事React项目,并且已经开发了基本组件。昨天一切都很好。然后,我开始了一个新的react native项目。使用create-react-native-app安装项目后,npm start命令无法启动服务器,但对于react项目来说运行正常。

我正在使用节点10.6和npm 5.6。阅读一些建议后,我将node更改为v8.11,将npm更改为6.2。安装了watchman并更改了inotify手表之后,我终于让该本机应用程序启动了。

今天,我尝试启动react项目,但服务器未启动。 这就是终端显示的内容...

  Starting the development server...

events.js:183
      throw er; // Unhandled 'error' event
      ^

Error: watch /home/maneesh/source_code/react/ytc/public ENOSPC
    at _errnoException (util.js:992:11)
    at FSWatcher.start (fs.js:1382:19)
    at Object.fs.watch (fs.js:1408:11)
    at createFsWatchInstance (/home/maneesh/source_code/react/ytc/node_modules/webpack-dev-server/node_modules/chokidar/lib/nodefs-handler.js:37:15)
    at setFsWatchListener (/home/maneesh/source_code/react/ytc/node_modules/webpack-dev-server/node_modules/chokidar/lib/nodefs-handler.js:80:15)
    at FSWatcher.NodeFsHandler._watchWithNodeFs (/home/maneesh/source_code/react/ytc/node_modules/webpack-dev-server/node_modules/chokidar/lib/nodefs-handler.js:228:14)
    at FSWatcher.NodeFsHandler._handleDir (/home/maneesh/source_code/react/ytc/node_modules/webpack-dev-server/node_modules/chokidar/lib/nodefs-handler.js:407:19)
    at FSWatcher.<anonymous> (/home/maneesh/source_code/react/ytc/node_modules/webpack-dev-server/node_modules/chokidar/lib/nodefs-handler.js:455:19)
    at FSWatcher.<anonymous> (/home/maneesh/source_code/react/ytc/node_modules/webpack-dev-server/node_modules/chokidar/lib/nodefs-handler.js:460:16)
    at FSReqWrap.oncomplete (fs.js:153:5)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! ytc@0.1.0 start: `react-scripts start`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the ytc@0.1.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

我正在使用Ubuntu 18.04 节点8.11 npm 6.2

知道可能是什么问题吗?

2 个答案:

答案 0 :(得分:0)

  

您可以运行以下命令来避免使用ENOSPC:

     

$ sed "s/^\(.\{,36\}\)$/\1`echo -$_{1..30}|tr -d '-'`/; s/^\(.\{38\}\) /\1-/; s/^\(.\{43\}\) /\1-/; s/^\(.\{50\}\) /\1-/; s/^\(.\{57\}\) /\1-/; s/^\(.\{64\}\) /\1-/; s/^\(.\{73\}\) /\1-/; s/ *$//" I_BLENDER_0/R_137/CLK (SDFFX2_HVT) - - 0.20 - 0.00 0.00 r I_BLENDER_0/R_137/Q (SDFFX2_HVT) - - 0.08 - 0.34 & 0.34 r I_BLENDER_0/n2757 (net) 6 12.95 I_BLENDER_0/U4847/A1 (AND2X1_LVT) - 0.00 0.08 0.00 0.00 & 0.35 r I_BLENDER_0/U4847/Y (AND2X1_LVT) - - 0.07 - 0.08 & 0.42 r I_BLENDER_0/n2616 (net) 6 8.70

     

对于Arch Linux,将此行添加到/etc/sysctl.d/99-sysctl.conf:

     

density <- rnorm(50, 0.8, 0.3) carbonate <- rnorm(50, 75, 18) org_per <- rnorm(50, 0.9, 1.1) Depth_decomp <- seq(1,151,3) Age <- seq(0,5600, 112) df <- data.frame(cbind(density, carbonate, org_per, Depth_comp, Age))

     

最后,运行:

     

library(ggplot2) library(data.table) library(grid) library(gridExtra) library(gtable) p1 <- ggplot(df[,c(1,4)], aes(x=density, y=Depth_decomp)) + theme_bw() + geom_path() + labs(x=bquote('Density'~(gDWcm^-3)), y='Depth (cm)') + scale_y_reverse()+ theme(axis.line=element_line(), axis.line.y = element_line(), panel.background= element_blank(), panel.border = element_blank()) p2 <- ggplot(df[,c(2,4)], aes(x=carbonate, y=Depth_decomp)) + theme_bw() + geom_path() + labs(x=expression(CaCO[3]*" (%)"), y=NULL) + scale_x_continuous(position="top") + scale_y_reverse(breaks=NULL)+ theme(axis.line=element_line(), panel.background= element_blank(), panel.border = element_blank()) p3 <- ggplot(df[,c(3,5)], aes(x=org_per, y=Age)) + theme_bw() + geom_path() + labs(x="Organic matter (%)", y = "Ages (Cal yr BP)")+ scale_y_reverse(position="right", breaks =seq(0,6000, by=1000))+ scale_x_continuous() + theme(axis.line=element_line(), panel.background= element_blank(), panel.border = element_blank()) gt1 <- ggplotGrob(p1) gt2 <- ggplotGrob(p2) gt3 <- ggplotGrob(p3) newWidth = unit.pmax(gt1$widths[2:3], gt2$widths[2:3], gt3$widths[2:3]) gt1$widths[2:3] = as.list(newWidth) gt2$widths[2:3] = as.list(newWidth) gt3$widths[2:3] = as.list(newWidth) gt = gtable(widths = unit(c(1, 1, 1, .3), "null"), height = unit(1, "null")) gt <- gtable_add_grob(gt, gt1, 1, 1) gt <- gtable_add_grob(gt, gt2, 1, 2) gt <- gtable_add_grob(gt, gt3, 1, 3) grid.newpage() grid.draw(gt)

     

这还将在重新启动后持续存在。

来源:https://github.com/guard/listen/wiki/Increasing-the-amount-of-inotify-watchers#the-technical-details

答案 1 :(得分:-2)

尝试

create-react-app my-app
cd my-app
npm install react-scripts@2.1.8
npm start