Stacks.js: [CLI] Requires global typescript installation

Created on 24 Mar 2021  路  2Comments  路  Source: blockstack/stacks.js

I've seen users encounter this on Discord and also ran into it myself.

Here's the stacktrace, but gist is that the CLI requires a global install of typescript.

Resolution
Remove typescript as a global dependency.

Recreate
Clean install / remove global typescript dep and try running cli.

node:internal/modules/cjs/loader:927
  throw err;
  ^

Error: Cannot find module 'typescript'
Require stack:
- /Users/kyranjamie/.config/yarn/global/node_modules/ts-node/dist/index.js
- /Users/kyranjamie/.config/yarn/global/node_modules/@stacks/cli/bin.js
    at Function.Module._resolveFilename (node:internal/modules/cjs/loader:924:15)
    at Function.resolve (node:internal/modules/cjs/helpers:98:19)
    at loadCompiler (/Users/kyranjamie/.config/yarn/global/node_modules/ts-node/dist/index.js:185:34)
    at create (/Users/kyranjamie/.config/yarn/global/node_modules/ts-node/dist/index.js:190:28)
    at Object.register (/Users/kyranjamie/.config/yarn/global/node_modules/ts-node/dist/index.js:162:21)
    at Object.<anonymous> (/Users/kyranjamie/.config/yarn/global/node_modules/@stacks/cli/bin.js:3:20)
    at Module._compile (node:internal/modules/cjs/loader:1092:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1121:10)
    at Module.load (node:internal/modules/cjs/loader:972:32)
    at Function.Module._load (node:internal/modules/cjs/loader:813:14) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    '/Users/kyranjamie/.config/yarn/global/node_modules/ts-node/dist/index.js',
    '/Users/kyranjamie/.config/yarn/global/node_modules/@stacks/cli/bin.js'
  ]
}
bug

Most helpful comment

The same situation.
You should do npm install -g typescript before npm install @stacks/cli

All 2 comments

The same situation.
You should do npm install -g typescript before npm install @stacks/cli

Similar to #964

See: https://github.com/blockstack/stacks.js/issues/964#issuecomment-812455616

ts-node has typescript as a peerDependency, and peer dependencies are not installed by default from NPM v3-v6. NPM 7 reintroduced the automatic installation of peer dependencies.
The issue is no longer present on the latest NPM version. To fix it for those using older versions of NPM, listing typescript as a dependency is the only solution.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

yknl picture yknl  路  5Comments

larrysalibra picture larrysalibra  路  6Comments

muneeb-ali picture muneeb-ali  路  8Comments

agraebe picture agraebe  路  3Comments

chris-asl picture chris-asl  路  8Comments