https://github.com/markthree/nitro-port-module
Allow changing the nitro default port | 允许改变 nitro 默认 port
https://github.com/markthree/nitro-port-module
module nitro nitropack node port
Last synced: 3 months ago
JSON representation
Allow changing the nitro default port | 允许改变 nitro 默认 port
- Host: GitHub
- URL: https://github.com/markthree/nitro-port-module
- Owner: markthree
- License: mit
- Created: 2024-02-05T11:59:35.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-02-23T13:31:03.000Z (over 1 year ago)
- Last Synced: 2024-04-24T13:44:31.138Z (about 1 year ago)
- Topics: module, nitro, nitropack, node, port
- Language: TypeScript
- Homepage:
- Size: 156 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# nitro-port-module
Allow changing the nitro default port
## README 🦉
[简体中文](./README_CN.md) | English
## Usage
### install
```shell
npm i nitro-port-module -D
```### Configuration Module
> nuxt
```ts
// nuxt.config.ts
import nitroPort from "nitro-port-module";export default defineNuxtConfig({
nitro: {
modules: [
nitroPort({
port: 4000,
}),
],
},
});
```> nitro
```ts
// nitro.config.js
import nitroPort from "nitro-port-module";export default defineNitroConfig({
modules: [
nitroPort({
port: 4000,
}),
],
});
```#### polyfill
Default automatic detection
```ts
// nuxt.config.ts
import nitroPort from "nitro-port-module";export default defineNuxtConfig({
nitro: {
modules: [
nitroPort({
port: 4000,
polyfill(nitro, port) {
return nitro.options.preset.includes("deno")
? `Deno.env.set("PORT", "${port}")`
: `process.env.PORT = '${port}'`;
},
}),
],
},
});
```### compatible
In older versions of Nuxt3, there might not be Nitro modules. In this case, you
can try using the following configuration.```ts
import { ViteNitroPort } from "nitro-port-module";export default defineNuxtConfig({
devServer: {
port: 5000,
},
vite: {
plugins: [
ViteNitroPort({
port: 5000,
}),
],
},
});
```
## License
Made with [markthree](https://github.com/markthree)
Published under [MIT License](./LICENSE).