使用npm仓库的create-near-app创建AssemblyScript+React项目时遭遇NEAR环境「Sorry, assemblyscript is not supported in your system, use --contract=rust」错误的解决方法咨询
Let’s break down how to resolve this error when setting up an AssemblyScript + React NEAR project using create-near-app. This message typically pops up due to missing system dependencies for AssemblyScript or changes in how recent versions of create-near-app handle contract templates. Here’s what to try step by step:
1. Verify your Node.js version
AssemblyScript requires a modern Node.js environment (v16.x or newer is recommended). Run this command to check your current version:
node -v
If your version is older than v16, upgrade Node.js. Use a version manager like nvm (for macOS/Linux) or nvm-windows (for Windows) to easily install and switch to a supported version.
2. Install AssemblyScript globally (optional but helpful)
Sometimes create-near-app relies on a global AssemblyScript installation to detect system support. Install it via npm:
npm install -g assemblyscript
Confirm it’s installed correctly with:
asc --version
3. Explicitly specify the AssemblyScript contract template
Recent versions of create-near-app may default to Rust contracts, so you need to explicitly tell it to use AssemblyScript. Run your project creation command with the --contract=assemblyscript flag:
npx create-near-app my-near-project --contract=assemblyscript --frontend=react
This forces the tool to pull the AssemblyScript contract template instead of falling back to Rust.
4. For Windows users: Address compatibility issues
If you’re on Windows, AssemblyScript can sometimes struggle with native dependencies. Try these fixes:
- Use WSL2 (Windows Subsystem for Linux) to run commands in a Linux environment, which has better compatibility with NEAR tooling.
- Install Windows Build Tools by running
npm install -g windows-build-toolsin an elevated PowerShell prompt—this handles native compilation steps required by AssemblyScript dependencies.
5. Clear your npm cache and retry
Corrupted cache can cause unexpected errors. Clear it and re-run the project creation command:
npm cache clean --force npx create-near-app my-near-project --contract=assemblyscript --frontend=react
If none of these steps work, double-check that your system has all basic NEAR development prerequisites (like Git installed, since create-near-app uses it to clone templates).
内容的提问来源于stack exchange,提问作者samet mollaoglu

