TypeError [ERR_INVALID_ARG_TYPE] in appchain-truffle-box

It seems it is the first English topic in the forum…

I followed the README file of the Appchain truffle box repo. And when I try to run

npm run migrate

I got the following TypeError:

> [email protected] migrate /home/ubuntu/cita-truffle-box
> appchain-migrate migrate

TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received type object
    at assertPath (path.js:39:11)
    at Object.resolve (path.js:1090:7)
    at join (/home/ubuntu/cita-truffle-box/node_modules/find-up/index.js:11:14)
    at Function.module.exports.sync (/home/ubuntu/cita-truffle-box/node_modules/find-up/index.js:43:12)
    at Function.Config.detect (/home/ubuntu/cita-truffle-box/node_modules/@nervos/appchain-truffle-migrate/dist/config/index.js:347:21)
    at Object.run (/home/ubuntu/cita-truffle-box/node_modules/@nervos/appchain-truffle-migrate/dist/lib/commands/migrate.js:35:25)
    at Command.run (/home/ubuntu/cita-truffle-box/node_modules/@nervos/appchain-truffle-migrate/dist/lib/command.js:101:20)
    at Object.<anonymous> (/home/ubuntu/cita-truffle-box/node_modules/@nervos/appchain-truffle-migrate/dist/cli.js:23:9)
    at Module._compile (internal/modules/cjs/loader.js:689:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:700:10)
    at Module.load (internal/modules/cjs/loader.js:599:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:538:12)
    at Function.Module._load (internal/modules/cjs/loader.js:530:3)
    at Function.Module.runMain (internal/modules/cjs/loader.js:742:12)
    at startup (internal/bootstrap/node.js:266:19)
    at bootstrapNodeJSCore (internal/bootstrap/node.js:596:3)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] migrate: `appchain-migrate migrate`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the [email protected] migrate script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/ubuntu/.npm/_logs/2018-09-17T10_05_47_425Z-debug.log

And my truffle.js is:

module.exports = {
  networks: {
    network_name: {
      host: '121.196.200.225', // eg. '121.196.200.225'
      port: '1337', // eg. 1337
      network_id: '*', // Use '*' to match any network id
      privateKey: '0x5f0258a4778057a8a7d97809bd209055b2fbafa654ce7d31ec7191066b9225e6', // a string, required
    }, // you can add other network after here
  },
}

I have no idea what the path means?

change ‘network_name’ to ‘development’

module.exports = {
  networks: {
    development: {
      host: '121.196.200.225', // eg. '121.196.200.225'
      port: '1337', // eg. 1337
      network_id: '*', // Use '*' to match any network id
      privateKey: '0x5f0258a4778057a8a7d97809bd209055b2fbafa654ce7d31ec7191066b9225e6', // a string, required
    }, // you can add other network after here
  },
}

I changed it to ‘development’. But the same error still emerged. I checked the npm log:

0 info it worked if it ends with ok
1 verbose cli [ '/usr/local/bin/node', '/usr/local/bin/npm', 'run', 'migrate' ]
2 info using [email protected]
3 info using [email protected]
4 verbose run-script [ 'premigrate', 'migrate', 'postmigrate' ]
5 info lifecycle [email protected]~premigrate: [email protected]
6 info lifecycle [email protected]~migrate: [email protected]
7 verbose lifecycle [email protected]~migrate: unsafe-perm in lifecycle true
8 verbose lifecycle [email protected]~migrate: PATH: /usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin:/home/ubuntu/cita-truffle-box/node_modules/.bin:/home/ubuntu/.rbenv/shims:/home/ubuntu/.rbenv/bin:/home/ubuntu/.cargo/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin
9 verbose lifecycle [email protected]~migrate: CWD: /home/ubuntu/cita-truffle-box
10 silly lifecycle [email protected]~migrate: Args: [ '-c', 'appchain-migrate migrate' ]
11 silly lifecycle [email protected]~migrate: Returned: code: 1  signal: null
12 info lifecycle [email protected]~migrate: Failed to exec migrate script
13 verbose stack Error: [email protected] migrate: `appchain-migrate migrate`
13 verbose stack Exit status 1
13 verbose stack     at EventEmitter.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/index.js:301:16)
13 verbose stack     at EventEmitter.emit (events.js:182:13)
13 verbose stack     at ChildProcess.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/lib/spawn.js:55:14)
13 verbose stack     at ChildProcess.emit (events.js:182:13)
13 verbose stack     at maybeClose (internal/child_process.js:962:16)
13 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:249:5)
14 verbose pkgid [email protected]
15 verbose cwd /home/ubuntu/cita-truffle-box
16 verbose Linux 4.15.0-33-generic
17 verbose argv "/usr/local/bin/node" "/usr/local/bin/npm" "run" "migrate"
18 verbose node v10.8.0
19 verbose npm  v6.4.1
20 error code ELIFECYCLE
21 error errno 1
22 error [email protected] migrate: `appchain-migrate migrate`
22 error Exit status 1
23 error Failed at the [email protected] migrate script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 1, true ]

It seems the command appchain-migrate was not executed correctly.

May be there is something wrong with npm, use yarn to replace it.

yarn
yarn migrate

Yes, yarn works. And now I am trying to find out what happens to my npm

2 Likes

We will update the doc accordingly. Thank you for your feedback