1

I am trying to follow the truffle pet shop tutorial and I am doing my first truffle migration.

After this command:

truffle migrate

I get this error:

SyntaxError: Invalid or unexpected token at new Script (vm.js:74:7) at Object.createScript (vm.js:246:10) at /usr/local/lib/node_modules/truffle/build/webpack:/packages/truffle-require/require.js:96:1 at FSReqWrap.readFileAfterClose [as oncomplete] (internal/fs/read_file_context.js:53:3)

I tried installing the latest truffle, deleting the contract/build folder and compile again, changing the pragma solidity ^0.4.17; to pragma solidity ^0.4.24; to make Adoption.sol pragma version to be consistent with the one on Migrations.sol

Anyone solved this error before?

  • What is the content of your migrations scripts? Can you add the whole output of the truffle migrate command? – Ismael Aug 16 '18 at 1:03
  • (Solved) It was like this: 2_deploy_contracts.js. var Adoption = artifacts.require("Adoption"); module.exports = function(deployer) { deployer.deploy(Adoption); }; // It worked when I deleted the name of the file - on the file – Maruta Aug 16 '18 at 1:31
1

Solved, the problem that when I named the migrations file as 2_deploy_contracts.js, the name was placed on the file itself. Once I deleted this line, it worked

  • I am having the same problem. What do you mean by "the name was placed on the file itself"? do you mean it was within the code in the file or the title of the file? – Zakoff May 21 at 19:48
  • 1
    it was in the code in the file – Maruta May 23 at 7:34
1

Same problem here when I was following the tutorial of Dapp University. Deleted the 2_deploy_contracts.js file and it works.

  • 1
    It is more common to make your modifications in 2_deploy_contracts.js and leave the script 1_initial_migration.js alone. But it should work if you modify only one and delete the other. – Ismael Oct 21 '18 at 22:08

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.