node.js - 如何在 WSL 中切换 Node 项目?
问题描述
使用 开始一个项目后npm init
,我如何:a) 切换到另一个项目,b) 回到这个项目并稍后继续?这是否需要某种项目经理?
我试图找到 nodejs 项目经理,虽然我被提到 pm2 并且永远,但是 pm2 似乎超级复杂,我什至不确定它是否能满足我的需要,并且永远运行一个特定的脚本。. . 出色地。. . 永远,这也不是我想要的。
要开始一个项目,我使用:npm init
当然,我可以创建一个项目,但我不知道如何暂时关闭项目和/或稍后切换回它并继续。
解决方案
It's really not so complicated. You can create two projects as long as they're in different directories like this.
user@machine:~$ mkdir src
user@machine:~$ cd src
user@machine:~/src$ mkdir project1
user@machine:~/src$ cd project1
user@machine:~/src/project1$ npm init
(...follow the prompts here)
user@machine:~/src/project1$ cd ..
user@machine:~/src$ mkdir project2
user@machine:~/src$ cd project2
user@machine:~/src/project2$ npm init
(...follow the prompts here)
user@machine:~/src/project2$ cd ..
This will leave you with ~/src/project1/package.json
and ~/src/project2/package.json
The package.json files are just text files. Neither node nor npm keep the package.json file open.
But, you can open the package.json file in your favourite editor to make changes. Save the changes when you are done. Closing the file again in your editor is up to you, depending on whether or not you want to make further changes.
推荐阅读
- html - 带有 jQuery 问题的 Div
- reactjs - 如何同时从 Firebase 和 setState 中提取多个数据
- r - 将行附加到 R 中的现有数据框
- php - 如何在while循环中为php上的表更改数组键
- swift - 在 Combine 中,您如何创建一个发送一个值但从未完成的发布者?
- c - 按值交换结构(指针数组)
- android - 从 Google Cloud Firestore 中移除地图元素
- javascript - Javascript - 选择标签在 Draggable Parent 中不起作用
- c++ - C++为什么不能重新声明类成员函数但普通函数可以
- kotlin - Kotlin 打印 IntArray 内容的方式是什么?