SaraVieira / preact-cli-plugin-flow

Use flow with the Preact CLI
MIT License
17 stars 4 forks source link

installing via Yarn fails #6

Open moebiusmania opened 6 years ago

moebiusmania commented 6 years ago

hi, I've tried different times to install this package via Yarn but it always fails. Installing with NPM is fine.

At the moment I don't have any idea of a possible reason.

d2s commented 6 years ago

Same problem here.

Looking at the source code, it appears that the issue is caused by the hardcoded npm command in the bin/index.js file.

function installFlowBin() {
    spinner.start('Installing Dependencies')
    exec('npm install --save-dev flow-bin', { cwd: root }, error => {

There should be some type of feature checking for looking whether Yarn is installed or not. If yarn is available (and yarn.lock file is present at the project's directory), it should be used instead of npm command.

(Yarn has bugs that cause issues if both npm and yarn commands are used to manage same set of packages.)

After the command is run, unneeded package-lock.json file is created (as it duplicates the things done by yarn.lock file).

yarn add preact-cli-plugin-flow --dev

Console log

$ yarn add preact-cli-plugin-flow --dev
yarn add v1.3.2
[1/4] Resolving packages...
warning preact-cli-plugin-flow > flow-typed > github@0.2.4: 'github' has been renamed to '@octokit/rest' (https://git.io/vNB11)
warning preact-cli-plugin-flow > flow-typed > unzip > fstream > graceful-fs@3.0.11: please upgrade to graceful-fs 4 for compatibility with current and future versions of Node.js
[2/4] Fetching packages...
info fsevents@1.1.3: The platform "linux" is incompatible with this module.
info "fsevents@1.1.3" is an optional dependency and failed compatibility check. Excluding it from installation.
[3/4] Linking dependencies...
warning " > carbon-components-react@5.21.0" has unmet peer dependency "react@^15.3.2 || ^16.1.0".
warning " > carbon-components-react@5.21.0" has unmet peer dependency "react-dom@^15.3.2 || ^16.1.0".
warning "carbon-components-react > downshift@1.28.0" has unmet peer dependency "prop-types@>=15".
warning "carbon-components-react > downshift@1.28.0" has unmet peer dependency "react@>=15".
warning "preact-cli > babel-loader@7.1.2" has unmet peer dependency "babel-core@6 || 7 || ^7.0.0-alpha || ^7.0.0-beta || ^7.0.0-rc".
warning " > sass-loader@6.0.6" has unmet peer dependency "webpack@^2.0.0 || >= 3.0.0-rc.0 || ^3.0.0".
[4/4] Building fresh packages...
[-/6] ⡀ waiting...
[-/6] ⡀ waiting...
[-/6] ⢀ waiting...
[6/6] ⢀ preact-cli
error /[...]/project_name/node_modules/preact-cli: Command failed.
Exit code: 1
Command: node -p 'require("./check.js")()'
Arguments: 
Directory: /[...]/project_name/node_modules/preact-cli
Output:
module.js:540
    throw err;
    ^

Error: Cannot find module './check.js'
    at Function.Module._resolveFilename (module.js:538:15)
    at Function.Module._load (module.js:468:25)
    at Module.require (module.js:587:17)
    at require (internal/module.js:11:18)
    at [eval]:1:1
    at ContextifyScript.Script.runInThisContext (vm.js:50:33)
    at Object.runInThisContext (vm.js:139:38)