merklejerk / solpp

A solidity preprocessor and flattener CLI and library
Apache License 2.0
112 stars 14 forks source link

Odd "MODULE_NOT_FOUND" out of nowhere #7

Open deluca-mike opened 3 years ago

deluca-mike commented 3 years ago

slopp was working perfectly fine, then just did a reinstall/upgrade of another unrelated package with yarn, and now this:

$ yarn precompile
yarn run v1.22.10

$ solpp --no-flatten --defs configs/definitions.json --output eth/contracts/library.sol eth/pre-contracts/library.sol
internal/modules/cjs/loader.js:883
  throw err;
  ^

Error: Cannot find module 'antlr4/index'
Require stack:
- /Users/MY_USERNAME/Projects/MY_PROJECT/node_modules/solpp/src/antlr/SolLexer.js
- /Users/MY_USERNAME/Projects/MY_PROJECT/node_modules/solpp/src/oven.js
- /Users/MY_USERNAME/Projects/MY_PROJECT/node_modules/solpp/src/index.js
- /Users/MY_USERNAME/Projects/MY_PROJECT/node_modules/solpp/src/solpp.js
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:880:15)
    at Function.Module._load (internal/modules/cjs/loader.js:725:27)
    at Module.require (internal/modules/cjs/loader.js:952:19)
    at require (internal/modules/cjs/helpers.js:88:18)
    at Object.<anonymous> (/Users/MY_USERNAME/Projects/MY_PROJECT/node_modules/solpp/src/antlr/SolLexer.js:3:14)
    at Module._compile (internal/modules/cjs/loader.js:1063:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
    at Module.load (internal/modules/cjs/loader.js:928:32)
    at Function.Module._load (internal/modules/cjs/loader.js:769:14)
    at Module.require (internal/modules/cjs/loader.js:952:19) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    '/Users/MY_USERNAME/Projects/MY_PROJECT/node_modules/solpp/src/antlr/SolLexer.js',
    '/Users/MY_USERNAME/Projects/MY_PROJECT/node_modules/solpp/src/oven.js',
    '/Users/MY_USERNAME/Projects/MY_PROJECT/node_modules/solpp/src/index.js',
    '/Users/MY_USERNAME/Projects/MY_PROJECT/node_modules/solpp/src/solpp.js'
  ]
}

Using node 14.15.1

deluca-mike commented 3 years ago

npm install does seem to fix this. yarn install breaks it.

Despite solpp 0.11.2 specifying antlr4: ^4.7.1 yarn is pulling antlr4@4.9.0 which seems to have made changes that break solpp (in how it was being imported).

Will try upgrading yarn.

Confirmed. Installing solpp with yarn is busted. Use npm.

dorothy-zbornak commented 3 years ago

Thanks for flagging this. I pinned the version of antlr4 to ~4.8.0. Should be fixed in 0.11.3!