【问题标题】:Does making changes in files in node_modules restart nodemon?对 node_modules 中的文件进行更改是否会重新启动 nodemon?
【发布时间】:2020-09-21 13:49:22
【问题描述】:

 {
      "scripts": {
        "test": "echo \"Error: no test specified\" && exit 1",
        "start": "node bin/server.js",
        "dev":"nodemon bin/server.js"
      },
      "dependencies": {
        "@babel/cli": "^7.8.4",
        "@babel/core": "^7.9.0",
        "@babel/preset-env": "^7.9.5",
        "@babel/preset-react": "^7.9.4",
        "axios": "^0.19.2",
        "babel-loader": "^8.1.0",
        "babel-plugin-transform-class-properties": "^6.24.1",
        "babel-plugin-transform-object-rest-spread": "^6.26.0",
        "express": "^4.17.1",
        "mongodb": "^3.5.7",
        "mongoose": "^5.9.15",
        "react": "^16.13.1",
        "react-addons-shallow-compare": "^15.6.2",
        "react-dates": "^12.7.0",
        "react-dom": "^16.13.1",
        "webpack": "^4.43.0",
        "webpack-dev-server": "^3.10.3",
        "webpack-hot-middleware": "^2.25.0"
      },
      "devDependencies": {
        "nodemon": "^2.0.4",
        "webpack-cli": "^3.3.11"
      }
    }

当我在src 文件夹中进行更改时,nodemon 会重新启动我的服务器。但是,当我对core-npm 中存在的文件进行更改时,node_modules 中的文件nodemon 不会重新启动。

可以用nodemon 完成还是有其他方法可以做到?

【问题讨论】:

  • node_modules 默认被忽略。你可以在你的 nodemon 配置中覆盖它github.com/remy/nodemon/blob/master/…
  • nodemon.json应该保存在哪里?我可以忽略除 core-npm 之外的所有 node_modules 吗?

标签: node.js reactjs express nodemon


【解决方案1】:
nodemon bin/server.js --watch . --watch folderLocation/core-npm

上面的代码也将监视指定位置的变化。对我来说,它是core-npm in node_modules

【讨论】:

  • 虽然此代码可以解决问题,including an explanation 说明如何以及为什么解决问题将真正有助于提高您的帖子质量,并可能导致更多的赞成票。请记住,您正在为将来的读者回答问题,而不仅仅是现在提问的人。请edit您的回答添加解释并说明适用的限制和假设。
猜你喜欢
  • 1970-01-01
  • 2020-11-08
  • 2018-07-08
  • 2019-03-23
  • 2016-10-10
  • 1970-01-01
  • 2014-09-24
  • 2020-06-15
相关资源
最近更新 更多