VS2017是否支持Solidity?Win10安装步骤及truffle.js报错咨询
Hey there! Let's break down your questions and fix that error step by step:
Does Visual Studio 2017 Support Solidity?
Absolutely! Visual Studio 2017 does support Solidity development, but you’ll need to install a dedicated extension to add syntax highlighting, IntelliSense, and other Solidity-specific tools. The most reliable extension is the Solidity for Visual Studio package (maintained by community contributors and compatible with VS2017).
Windows 10: Step-by-Step Solidity Setup for VS2017
Follow these steps to get Solidity up and running in your VS2017 environment:
Update Visual Studio 2017 First
- Open VS2017, go to
Tools > Get Tools and Features. - Ensure the Node.js Development workload is installed (this helps with tools like Truffle later). If it’s missing, check the box and click
Modifyto install it.
- Open VS2017, go to
Install the Solidity Extension
- In VS2017, navigate to
Tools > Extensions and Updates. - Switch to the
Onlinetab, search for Solidity in the search bar. - Pick the top-rated extension (usually just named "Solidity") and click
Download. Restart VS2017 once the download finishes to complete installation.
- In VS2017, navigate to
Set Up the Solidity Compiler (solc)
- If you don’t have Node.js installed, grab version 12+ (Truffle works best with this range) from the official Node.js site.
- Open an elevated Command Prompt (right-click > Run as administrator) and run:
npm install -g solc - Verify the installation by running
solc --versionin the command line—you should see the compiler version printed.
Optional: Install Truffle Framework (for DApp Development)
- If you’re building decentralized applications, install Truffle via npm:
npm install -g truffle - Initialize a new Truffle project in your desired folder:
mkdir MySolidityDApp cd MySolidityDApp truffle init
- If you’re building decentralized applications, install Truffle via npm:
Fixing the 'module' is undefined JScript Runtime Error
That error happens because Windows is trying to run your truffle.js file with Microsoft JScript (the default handler for .js files) instead of Node.js. Here’s how to fix it:
Set Node.js as the Default Handler for .js Files
- Right-click any
.jsfile on your system, selectOpen with > Choose another app. - Select
Node.jsfrom the list (if it’s not visible, clickMore appsand navigate to your Node.js installation folder—usuallyC:\Program Files\nodejs\node.exe). - Check the box "Always use this app to open .js files" and click
OK.
- Right-click any
Verify the Fix
- Open Command Prompt, navigate to your Truffle project folder, and run:
truffle compile - The error should disappear, as Node.js will now properly execute the
.jsconfiguration files.
- Open Command Prompt, navigate to your Truffle project folder, and run:
Alternative: Run Truffle Explicitly via Node.js
- If you don’t want to change default file handlers, you can run Truffle directly using Node.js:
node C:\Users\<YourUsername>\AppData\Roaming\npm\node_modules\truffle\build\cli.bat compile - Replace
<YourUsername>with your actual Windows username.
- If you don’t want to change default file handlers, you can run Truffle directly using Node.js:
内容的提问来源于stack exchange,提问作者sravanthi vallepu

