I used npm install to install my node package dependencies. My node package dependencies look like the following:
"dependencies": {
"blockcypher": "^0.2.0",
"fs-extra": "^7.0.1",
"ganache-cli": "^6.2.4",
"mocha": "^5.2.0",
"openzeppelin-solidity": "^2.0.0",
"solc": "^0.4.24"
}
When I run the following compile script using node I get the following error within EVERY contract that has an import statement that references dependency in my node_modules.
I'm using Solidity Version: ^0.4.24
Solidity Error: ParseError: Source "node_modules/openzeppelin-solidity/ect.." not found
const path = require("path"); //Delete all the contents in the build folder
const solc = require("solc"); //solidity compiler
const fs = require("fs-extra"); // Gives us access to the file system
//Require The Import Statements From The Contract
// import "node_modules/openzeppelin-solidity/contracts/token/ERC20/ERC20.sol";
// import "node_modules/openzeppelin-solidity/contracts/ownership/Ownable.sol";
// import "node_modules/openzeppelin-solidity/contracts/token/ERC20/IERC20.sol";
//var data = require("node_modules/openzeppelin-solidity/contracts/token/ERC20/ERC20.json");
//How do I use this?
const buildPath = path.resolve(__dirname, "build");
fs.removeSync(buildPath);
const campainPath = path.resolve(__dirname, "Contract.sol");
// const campainPath = path.resolve(__dirname, "contracts", "Esgro.sol");
const source = fs.readFileSync(campainPath, "utf8");
console.log("\n\n\t Compilation Output \n\n\n");
console.log(solc.compile(source, 1));
const output = solc.compile(source, 1).contracts; //Internal Error
console.log("\n\n\t Compilation Output \n\n\n");
console.log(output);
fs.ensureDirSync(buildPath);
for (let contract in output) {
// fs.outputJsonSync(
// path.resolve(buildPath, contract.replace(":"", "") + ".json"),
// output[contract]
// );
console.log("\n\n\t output[contract] \n\n\n");
console.log(output[contract]);
fs.outputJsonSync(path.resolve(buildPath, contract), output[contract]);
}
//Compile both contracts with the solc compiler
//Write the output to the build directory
How do you get the compiler to "connect" with the third party dependencies on a local machine? Any help or pointers would be greatly appreciated.