运行 节点和反应在不同的文件夹中同时进行
Run Node & React Concurrently in separate folders
我的应用程序确实有效,但我想重新组织它以便于管理。我想将服务器文件从根目录移动到它们自己的目录。
目前我使用并发来加载我的服务器和客户端,这样他们就可以同时运行。
当我 运行 npm 运行 dev 我想同时加载服务器和客户端。当 运行 服务器加载时,客户端失败,并在服务器目录中生成一个名为 client 的新文件夹。
我的新文件夹结构
client
client/package.json
server
server/package.json
以前的(工作)文件夹结构
server files in root
package.json {for server}
/client {all client files including /client/package.json}
我正在同时使用,并且正在尝试让它现在工作。我想我需要做的是在我的 server/package.json 文件中更改为正确的语法,但更改没有奏效。
同时在我的服务器中编码package.json文件
"dev": "concurrently \"npm run server\" \"npm run client\"",
我收到错误
] /bin/sh: ..npm: command not found
[1] ..npm run client exited with code 127
我已经尝试以不同的方式更改线路,但仍然无法让客户端加载
"dev": "concurrently \"npm run server\" \"cd ../client && /npm run client\"",
"dev": "concurrently \"npm run server\" \"cd ../client && /npm run client\"",
"dev": "concurrently \"npm run server\" \"npm run ./client\"",
"dev": "concurrently \"npm run server\" \"npm run ../client\"",
"dev": "concurrently \"npm run server\" \"npm run //client\"",
我认为这可能是一个简单的语法更改,但是正在创建一个新目录这一事实让我更加担心。任何解决方案或想法将不胜感激。
服务器 package.json 中的正确代码如下
"scripts": {
"start": "node server.js",
"server": "nodemon server.js",
**"client": "npm start --prefix ../client/",**
"clientinstall": "npm install --prefix client",
"dev": "concurrently \"npm run server\" \"npm run client\"",
"heroku-postbuild": "NPM_CONFIG_PRODUCTION=false npm install --prefix client && npm run build --prefix client "
},
我不得不在命令后放置新客户端目录的路径。现在我知道这似乎很明显,但我专注于另一条线。
在第二个参数中组合两个命令,以客户端位置和 npm 命令为目标
"dev": "concurrently \"npm run server\" \"cd ../client && npm run client\"",
我的应用程序确实有效,但我想重新组织它以便于管理。我想将服务器文件从根目录移动到它们自己的目录。
目前我使用并发来加载我的服务器和客户端,这样他们就可以同时运行。
当我 运行 npm 运行 dev 我想同时加载服务器和客户端。当 运行 服务器加载时,客户端失败,并在服务器目录中生成一个名为 client 的新文件夹。
我的新文件夹结构
client
client/package.json
server
server/package.json
以前的(工作)文件夹结构
server files in root
package.json {for server}
/client {all client files including /client/package.json}
我正在同时使用,并且正在尝试让它现在工作。我想我需要做的是在我的 server/package.json 文件中更改为正确的语法,但更改没有奏效。
同时在我的服务器中编码package.json文件
"dev": "concurrently \"npm run server\" \"npm run client\"",
我收到错误
] /bin/sh: ..npm: command not found
[1] ..npm run client exited with code 127
我已经尝试以不同的方式更改线路,但仍然无法让客户端加载
"dev": "concurrently \"npm run server\" \"cd ../client && /npm run client\"",
"dev": "concurrently \"npm run server\" \"cd ../client && /npm run client\"",
"dev": "concurrently \"npm run server\" \"npm run ./client\"",
"dev": "concurrently \"npm run server\" \"npm run ../client\"",
"dev": "concurrently \"npm run server\" \"npm run //client\"",
我认为这可能是一个简单的语法更改,但是正在创建一个新目录这一事实让我更加担心。任何解决方案或想法将不胜感激。
服务器 package.json 中的正确代码如下
"scripts": {
"start": "node server.js",
"server": "nodemon server.js",
**"client": "npm start --prefix ../client/",**
"clientinstall": "npm install --prefix client",
"dev": "concurrently \"npm run server\" \"npm run client\"",
"heroku-postbuild": "NPM_CONFIG_PRODUCTION=false npm install --prefix client && npm run build --prefix client "
},
我不得不在命令后放置新客户端目录的路径。现在我知道这似乎很明显,但我专注于另一条线。
在第二个参数中组合两个命令,以客户端位置和 npm 命令为目标
"dev": "concurrently \"npm run server\" \"cd ../client && npm run client\"",