Truffle flattener produces empty file

cd to folder and call npm truffle-flattener ./contracts/myToken.sol > ./contracts/myToken_flat.sol

results in producing a .sol file which has the following contents:

Usage: npm

where is one of:
access, adduser, audit, bin, bugs, c, cache, ci, cit,
clean-install, clean-install-test, completion, config,
create, ddp, dedupe, deprecate, dist-tag, docs, doctor,
edit, explore, fund, get, help, help-search, hook, i, init,
install, install-ci-test, install-test, it, link, list, ln,
login, logout, ls, org, outdated, owner, pack, ping, prefix,
profile, prune, publish, rb, rebuild, repo, restart, root,
run, run-script, s, se, search, set, shrinkwrap, star,
stars, start, stop, t, team, test, token, tst, un,
uninstall, unpublish, unstar, up, update, v, version, view,

npm -h quick help on
npm -l display full usage info
npm help search for help on
npm help npm involved overview

Specify configs in the ini-formatted file:
or on the command line via: npm --key value
Config info can be viewed via: npm help config

:computer: Environment
newest truffle, 0.6.2 pragma, windows 10

:1234: Code to reproduce
cd to folder and enter:
npm truffle-flattener ./contracts/myToken.sol > ./contracts/myToken_flat.sol

1 Like

In the truffle project, maybe you should run the following commands:

npm install truffle-flattener -g
truffle-flattener ./contracts/myToken.sol > ./contracts/myToken_flat.sol
1 Like

Hi @jing,

The issue appears to be that you are calling npm truffle-flattener when you should use npx if you don’t want to install.

You can try npx truffle-flattener ./contracts/myToken.sol > ./contracts/myToken_flat.sol which will run truffle-flattener without installing it.

Otherwise as per @Skyge (:pray: thanks as always) you can install globally and run.

Where possible I recommend doing multi-file verification using Truffle or Hardhat: Verify smart contract inheriting from OpenZeppelin Contracts

Hi @jing,

Were you able to verify your contract?

1 Like