[Truffle] migration returns "Cannot read property 'addFunction' of undefined"

 i am having this error when i run truffle migrate....
TypeError: Error parsing F:/nft/contracts/contracts/Migrations.sol: Cannot read property 'addFunction' of undefined
at runWithReadCallback (F:\node\node_modules\truffle\build\webpack:~\solc\wrapper.js:37:1)
at compileStandard (F:\node\node_modules\truffle\build\webpack:~\solc\wrapper.js:78:1)
at Object.compileStandardWrapper (F:\node\node_modules\truffle\build\webpack:~\solc\wrapper.js:85:1)
at Object.parseImports (F:\node\node_modules\truffle\build\webpack:\packages\truffle-compile\parser.js:47:1)
at Object.getImports (F:\node\node_modules\truffle\build\webpack:\packages\truffle-compile\profiler.js:374:1)
at F:\node\node_modules\truffle\build\webpack:\packages\truffle-compile\profiler.js:346:1

Truffle v5.0.5 (core: 5.0.5)
Node v14.16.0

Hi @coderbang1

Seems to be an issue with truffle, you are using an outdated version: https://github.com/trufflesuite/truffle/issues/3117

Update truffle to the latest version by running sudo npm i -g truffle

Keep me posted,
Dani

1 Like

dani, when i ran npm i- g truffle it gives me following error.

F:\node\parser -> F:\node\node_modules@babel\parser\bin\babel-parser.js
F:\node\acorn -> F:\node\node_modules\acorn\bin\acorn
F:\node\atob -> F:\node\node_modules\atob\bin\atob.js
F:\node\babylon -> F:\node\node_modules\babylon\bin\babylon.js
F:\node\detect-libc -> F:\node\node_modules\detect-libc\bin\detect-libc.js
F:\node\esparse -> F:\node\node_modules\esprima\bin\esparse.js
F:\node\esvalidate -> F:\node\node_modules\esprima\bin\esvalidate.js
F:\node\flat -> F:\node\node_modules\flat\cli.js
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {“os”:“darwin”,“arch”:“any”} (current: {“os”:“win32”,“arch”:“x64”})

npm ERR! code EEXIST
npm ERR! path F:\node\node_modules\he\bin\he
npm ERR! dest F:\node\he.cmd
npm ERR! File exists: F:\node\he.cmd
npm ERR! Remove the existing file and try again, or run npm
npm ERR! with --force to overwrite files recklessly.

npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\HP\AppData\Roaming\npm-cache_logs\2021-03-29T16_02_09_854Z-debug.log

dani, when i ran npm i- g truffle it gives me following error.

F:\node\parser -> F:\node\node_modules@babel\parser\bin\babel-parser.js
F:\node\acorn -> F:\node\node_modules\acorn\bin\acorn
F:\node\atob -> F:\node\node_modules\atob\bin\atob.js
F:\node\babylon -> F:\node\node_modules\babylon\bin\babylon.js
F:\node\detect-libc -> F:\node\node_modules\detect-libc\bin\detect-libc.js
F:\node\esparse -> F:\node\node_modules\esprima\bin\esparse.js
F:\node\esvalidate -> F:\node\node_modules\esprima\bin\esvalidate.js
F:\node\flat -> F:\node\node_modules\flat\cli.js
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {“os”:“darwin”,“arch”:“any”} (current: {“os”:“win32”,“arch”:“x64”})

npm ERR! code EEXIST
npm ERR! path F:\node\node_modules\he\bin\he
npm ERR! dest F:\node\he.cmd
npm ERR! File exists: F:\node\he.cmd
npm ERR! Remove the existing file and try again, or run npm
npm ERR! with --force to overwrite files recklessly.

npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\HP\AppData\Roaming\npm-cache_logs\2021-03-29T16_02_09_854Z-debug.log

1 Like

For the records:

The issue is related to an outdated version of Truffle.
Truffle has to be updated.


The user had another issue with the Truffle update wanted {“os”:“darwin”,“arch”:“any”} (current: {“os”:“win32”,“arch”:“x64”}) that was solved by forcing the npm pkg: sudo npm i -f -g truffle.

3 Likes