我正在尝试在Node程序中使用IP module。但是,每当我尝试使用const ip = require("ip")
添加它时,都会出现以下错误:
internal/modules/cjs/loader.js:584
throw err;
^
Error: Cannot find module 'ip'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:582:15)
at Function.Module._load (internal/modules/cjs/loader.js:508:25)
at Module.require (internal/modules/cjs/loader.js:637:17)
at require (internal/modules/cjs/helpers.js:22:18)
at Object.<anonymous> (/Users/fin444/Desktop/node/app.js:1:207)
at Module._compile (internal/modules/cjs/loader.js:701:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:712:10)
at Module.load (internal/modules/cjs/loader.js:600:32)
at tryModuleLoad (internal/modules/cjs/loader.js:539:12)
at Function.Module._load (internal/modules/cjs/loader.js:531:3)
为什么会这样?我已经在全球范围内多次在计算机上安装并重新安装了最新版本的IP,其他所有Node模块都可以正常工作。
答案 0 :(得分:1)
尝试一下:
box()
然后:
library(shiny)
library(shinydashboard)
library(ggplot2)
ui <- dashboardPage(
dashboardHeader(title = "Conditional plotOutput click", titleWidth = 450),
dashboardSidebar(disable = TRUE),
dashboardBody(
fluidRow(
tabBox(title = "Choose tab", id = "choose.tab", height = 250, selected = "Automatic",
tabPanel(title = "Automatic", id = "auto", sliderInput("slider", "Nobs:", 1, 10, 5)),
tabPanel(title = "Manual", id = "man")
),
box(title = "Plot", solidHeader = TRUE,
# plotOutput("plot1", height = 250) # Try me!
plotOutput("plot2", height = 250, click = "plot_click") # Or me!
)
)
)
)
server <- function(input, output) {
set.seed(123)
react.vals <- reactiveValues(
df = data.frame(x = numeric(), y = numeric()),
plot1 = ggplot(),
plot2 = ggplot()
)
# Plot 1 - Automatic scatterplot:
observe({
scatter.data <- data.frame(x = runif(input$slider), y = runif(input$slider))
react.vals$plot1 <- ggplot(scatter.data, aes(x, y)) + geom_point(color = "red", size = 4) +
scale_x_continuous("x", breaks = seq(0, 1, .2), limits = c(0, 1), expand = c(0,0)) +
scale_y_continuous("y", breaks = seq(0, 1, .2), limits = c(0, 1), expand = c(0,0)) +
theme(panel.grid.major = element_blank(), panel.grid.minor = element_blank())
})
observeEvent(react.vals$plot1, {
output$plot1 <- renderPlot({ react.vals$plot1 })
})
# Plot 2 - Manual scatterplot through clicking:
observeEvent(input$plot_click, {
new.point <- data.frame(x = input$plot_click$x,
y = input$plot_click$y)
react.vals$df <- rbind(react.vals$df, new.point)
})
observe({
react.vals$plot2 <- ggplot(react.vals$df, aes(x = x, y = y)) + geom_point(color = "red", size = 4) +
scale_x_continuous("x", breaks = seq(0, 1, .2), limits = c(0, 1), expand = c(0,0)) +
scale_y_continuous("y", breaks = seq(0, 1, .2), limits = c(0, 1), expand = c(0,0)) +
theme(panel.grid.major = element_blank(), panel.grid.minor = element_blank())
})
observeEvent(react.vals$plot2, {
output$plot2 <- renderPlot({ react.vals$plot2 })
})
}
shinyApp(ui, server)
我不知道是否需要--save,但是我遇到的问题是,如果没有该标志,则无法找到该模块。希望这会有所帮助。