I am trying to execute a script in my truffle project. The script is located in the scripts folder. But whether I run the command from within the root of the project or inside the scripts folder, it cant seem to find my file NiftRouter01.sol which is located in another project. I am using command truffle exec './deploy_pool.js' --network bscTestnet

        throw new Error("Could not find artifacts for " + import_path + " from any sources");

Error: Could not find artifacts for ../../niftswap-periphery/build/contracts/NiftRouter01.json from any sources
    at Resolver.require (C:\Users\DELL\AppData\Roaming\npm\node_modules\truffle\build\webpack:\packages\resolver\dist\lib\resolver.js:43:1)
    at D:\Blockchain\pancake\pancakeswap-core\scripts\deploy_pool.js:2:26
    at Script.runInContext (vm.js:131:20)
    at Script.runInNewContext (vm.js:137:17)
    at Object.file (C:\Users\DELL\AppData\Roaming\npm\node_modules\truffle\build\webpack:\packages\require\require.js:94:1)    
    at Object.exec (C:\Users\DELL\AppData\Roaming\npm\node_modules\truffle\build\webpack:\packages\require\require.js:121:1)   
    at internal/util.js:297:30
    at new Promise (<anonymous>)
    at bound exec (internal/util.js:296:12)
    at C:\Users\DELL\AppData\Roaming\npm\node_modules\truffle\build\webpack:\packages\core\lib\commands\exec.js:88:1
Truffle v5.1.49 (core: 5.1.49)
Node v12.18.0

I was able to resolve this by removing - from the script name, deleting node_modules folder and package.json and forcing npm cache clean. Also placed the script in an external folder.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.