next start command needs typescript?
Unanswered
Najmus Sakib posted this in #help-forum
If I run my application using
I ran
next version 15.4.6
node_modules/next/dist/bin/next start
▲ Next.js 15.4.6
- Local: http://localhost:3000
- Network: http://192.168.0.182:3000
✓ Starting...
⚠ Installing TypeScript as it was not found while loading "next.config.ts".
Installing devDependencies (pnpm):
- typescript
ERR_PNPM_INCLUDED_DEPS_CONFLICT modules directory (at "/Users/appifylab/projects/test-web") was installed with optionalDependencies, dependencies. Current install wants optionalDependencies, dependencies, devDependencies.
Failed to install TypeScript, please install it manually to continue:
pnpm add --save-exact --save-dev typescript
⨯ Failed to load next.config.ts, see more info here https://nextjs.org/docs/messages/next-config-error
{ command: 'pnpm add --save-exact --save-dev typescript' }
next start
after next build
command it is asking to required typescript. I ran
pnpm install -P
to install only dependency then why it's asking for typescript to present? next version 15.4.6
node_modules/next/dist/bin/next start
▲ Next.js 15.4.6
- Local: http://localhost:3000
- Network: http://192.168.0.182:3000
✓ Starting...
⚠ Installing TypeScript as it was not found while loading "next.config.ts".
Installing devDependencies (pnpm):
- typescript
ERR_PNPM_INCLUDED_DEPS_CONFLICT modules directory (at "/Users/appifylab/projects/test-web") was installed with optionalDependencies, dependencies. Current install wants optionalDependencies, dependencies, devDependencies.
Failed to install TypeScript, please install it manually to continue:
pnpm add --save-exact --save-dev typescript
⨯ Failed to load next.config.ts, see more info here https://nextjs.org/docs/messages/next-config-error
{ command: 'pnpm add --save-exact --save-dev typescript' }
8 Replies
@Najmus Sakib If I run my application using `next start` after `next build `command it is asking to required typescript.
I ran `pnpm install -P` to install only dependency then why it's asking for typescript to present?
next version 15.4.6
node_modules/next/dist/bin/next start
▲ Next.js 15.4.6
- Local: http://localhost:3000
- Network: http://192.168.0.182:3000
✓ Starting...
⚠ Installing TypeScript as it was not found while loading "next.config.ts".
Installing devDependencies (pnpm):
- typescript
ERR_PNPM_INCLUDED_DEPS_CONFLICT modules directory (at "/Users/appifylab/projects/test-web") was installed with optionalDependencies, dependencies. Current install wants optionalDependencies, dependencies, devDependencies.
Failed to install TypeScript, please install it manually to continue:
pnpm add --save-exact --save-dev typescript
⨯ Failed to load next.config.ts, see more info here https://nextjs.org/docs/messages/next-config-error
{ command: 'pnpm add --save-exact --save-dev typescript' }
i would imagine typescript is needed to run
next.config.ts
and if you use js
or mjs
instead for that config file it will not be necessarythat being said, why don't you use [output: standalone](https://nextjs.org/docs/app/api-reference/config/next-config-js/output#automatically-copying-traced-files)? seems suitable for what you are doing (which i assume is a docker build)
then you dont have to run
pnpm install
twice, once for building once for starting@joulev that being said, why don't you use [output: standalone](<https://nextjs.org/docs/app/api-reference/config/next-config-js/output#automatically-copying-traced-files>)? seems suitable for what you are doing (which i assume is a docker build)
So, my question is why it still read from source code next config file in production. in standalone mode next config also transform into javascript.
and I am not using docker. I just build my next application and create artifact without node_modules. then send the artifact to server and install only dependency then run
for now I moved typescript from devDependency to dependency. Also creating standalone build.
But I think this behaviour is wrong.
and I am not using docker. I just build my next application and create artifact without node_modules. then send the artifact to server and install only dependency then run
next start
but now it asking for to require typescript, because it still read config from next.config.ts. I think this should read from build config not the source config like standalone. for now I moved typescript from devDependency to dependency. Also creating standalone build.
But I think this behaviour is wrong.
- name: Cache turbo build setup
uses: actions/cache@v4
with:
path: .turbo
key: ${{ runner.os }}-turbo-${{ github.sha }}
restore-keys: |
${{ runner.os }}-turbo-
- uses: pnpm/action-setup@v4
name: Install pnpm
with:
run_install: false
- name: Use Node.js 22.x
uses: actions/setup-node@v4
with:
node-version: 22.x
cache: 'pnpm'
- name: Prune project
run: |
pnpm dlx turbo prune ezystudio-web --out-dir out
- name: Install dependencies
run: |
cd ${{ github.workspace }}/out
pnpm install --ignore-scripts --frozen-lockfile
- name: Build
run: |
cd ${{ github.workspace }}/out
pnpm build:sites
- name: Create deployment artifact
env:
GITHUB_SHA: ${{ github.sha }}
run: |
echo "Creating tarball for deployment"
cd ${{ github.workspace }}/out
tar --exclude='apps/ezystudio-web/.next/cache' \
--exclude='**/node_modules' \
--exclude='**/.turbo' \
-czf "${GITHUB_SHA}".tar.gz \
package.json pnpm-*.yaml turbo.json \
apps/ezystudio-web/{package.json,next.config.ts,ecosystem.config.js,.next,public}
echo "Created deployment artifact"
@Najmus Sakib So, my question is why it still read from source code next config file in production. in standalone mode next config also transform into javascript.
and I am not using docker. I just build my next application and create artifact without node_modules. then send the artifact to server and install only dependency then run `next start` but now it asking for to require typescript, because it still read config from next.config.ts. I think this should read from build config not the source config like standalone.
for now I moved typescript from devDependency to dependency. Also creating standalone build.
But I think this behaviour is wrong.
the build process without standalone mode does not emit a
since there is no
this does not apply to standalone mode. in that mode a
standalone mode does not assume whatever you have during build is still available during start, it only requires you to retain the output folder. hence standalone mode also does not require typescript to be installed.
i won't comment on whether this is right or wrong behaviour, i can only tell you how it currently works.
next.config.js
file. next start
assumes that whatever you have during build is still availble during start.since there is no
next.config.js
file emitted, there is no "build config file" and next start
must read the source config file, and, since your source config file is .ts
, it must have typescript installed to be evaluated.this does not apply to standalone mode. in that mode a
next.config.js
file is emitted and is used instead of the source file.standalone mode does not assume whatever you have during build is still available during start, it only requires you to retain the output folder. hence standalone mode also does not require typescript to be installed.
i won't comment on whether this is right or wrong behaviour, i can only tell you how it currently works.
Ok, so need to create standalone build. Thanks for your reply.
I am using turbo, so after creating standalone folder, need to exclude node_modules, Need to figure out what files need to include inside my artifact to run from monorepo. I found example but with docker, need to find without docker. will share if i success
I am using turbo, so after creating standalone folder, need to exclude node_modules, Need to figure out what files need to include inside my artifact to run from monorepo. I found example but with docker, need to find without docker. will share if i success
@Najmus Sakib Ok, so need to create standalone build. Thanks for your reply.
I am using turbo, so after creating standalone folder, need to exclude node_modules, Need to figure out what files need to include inside my artifact to run from monorepo. I found example but with docker, need to find without docker. will share if i success
for standalone build all files you need are just the
just send the
.next/standalone
folder. you don't need anything else, not even the rest of your monorepo.just send the
.next/standalone
folder and on the server, run node .next/standalone/server.js