Running yarn scripts in WebStorm with non-system node binary

I am trying to use WebStorm for a new project and use yarn instead of npm. However, after building the project, I cannot get the scripts to work through the yarn. My start script has the following launch configuration in WebStorm.

package.json: ~/dev/starting_sandbox/package.json
Command: run
Scripts: start
Node Interpreter: ~/.nvm/versions/node/v7.8.0/bin/node
Npm package: ~/.nvm/versions/node/v7.8.0/lib/node_modules/yarn

      

When this is done, I get an error:

/Users/byronsm/.nvm/versions/node/v7.8.0/bin/node /Users/byronsm/.nvm/versions/node/v7.8.0/lib/node_modules/yarn/bin/yarn.js run start
yarn run v0.21.3
$ react-scripts start 

~/dev/starting_sandbox/node_modules/cross-spawn/index.js:34
            throw new Error(
                  ^
Error: In order to use spawnSync on node 0.10 or older, you must install spawn-sync:

  npm install spawn-sync --save
    at Function.spawnSync [as sync] (~/dev/starting_sandbox/node_modules/cross-spawn/index.js:34:19)
    at Object.<anonymous> (~/dev/starting_sandbox/node_modules/react-scripts/bin/react-scripts.js:22:22)
    at Module._compile (module.js:456:26)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Function.Module.runMain (module.js:497:10)
    at startup (node.js:119:16)
    at node.js:929:3
error Command failed with exit code 8.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

      

I was able to solve this issue in webpack when running scripts via npm using the option --scripts-prepend-node-path

. However, it doesn't look like yarn.

The problem with the node instance seems to be that the yarn is triggered when scripts are executed, instead of pulling from the same node binary that is used to execute the yarn itself, it uses what it finds in the $ PATH, which does not change ...

Is there a similar command you can use for yarn?

+3


source to share





All Articles