You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

ngx-bootstrap项目构建失败:执行npm run test遇SyntaxError错误求助

Fix for SyntaxError: Unexpected token function in ngx-bootstrap build

It’s clear your Node.js version is too outdated to support the async/await syntax used in ngx-bootstrap’s build scripts. Let’s walk through fixing this step by step:

Step 1: Verify your current Node.js version

First, check what version you’re running—this will confirm the root issue:

node -v

Async functions are natively supported starting from Node.js 7.6, but ngx-bootstrap’s modern build tooling requires a more recent LTS version (Node.js 14.x or later is strongly recommended, as older versions are no longer maintained).

Step 2: Upgrade Node.js

If you have nvm installed, switching to the latest LTS version is straightforward:

nvm install --lts
nvm use --lts

This lets you manage multiple Node versions without messing with system-wide installs, which is great for working on different projects.

Option 2: Direct download

If you don’t use nvm, head to the official Node.js site, download the latest LTS installer for your OS, and run it to overwrite your current installation.

Step 3: Clean up old dependencies and cache

Before reinstalling, clear out leftover files to avoid conflicts:

# Delete the node_modules folder
rm -rf node_modules  # On Windows, use: rmdir /s /q node_modules

# Remove the lock file
rm package-lock.json  # Use rm yarn.lock instead if you use Yarn

# Clear npm's cache
npm cache clean --force

Step 4: Reinstall dependencies and run tests

Now you can rebuild and test without syntax errors:

npm install
npm run test

Why this error occurs

The crash in C:\Git\ngx-bootstrap\scripts\es2015\bundle.es2015.js line 12 happens because your Node.js version doesn’t recognize the async function syntax (an ES2017 feature). Since the pretest script depends on the build script (which runs this bundling script), the entire pipeline fails until you upgrade Node to a version that supports modern JavaScript features.

内容的提问来源于stack exchange,提问作者Beetlejuice

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.15 08:25:18