I keep seeing this behavior, so I want to understand it. I install gulp and the gulp-cli (not globally). Typing the gulp command gives me -bash: gulp: command not found
I take the gulp command and drop it into an npm script and boom, it works. Can someone explain what's going on here?
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"gulp": "gulp", // This works!!
"gulp-build": "gulp build" // As does this!!
},
Ahh, that makes sense. I was looking for the relative path to gulp in the project couldn't find the right path. Indeed ./node_modules/.bin/gulp does work. And thank you RobC for quoting that telling line in the docs. Totally makes sense now!
Related
Just started playing with Playwright. Installed and decided to run the tests that come with it. Can't figure out why it is failing.
$ npx playright tests
[11:09:04]
npm ERR! could not determine executable to run
FAIL
I've double check Typescript installed
$ tsc -v
Version 4.7.4
and nom
$ npm -v
8.1.0
I looked up solution on this site, and it mentions removing the .git/hooks file - I don't have that.
package.json is straight forward:
{
"name": "project01",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {},
"author": "",
"license": "ISC",
"devDependencies": {
"#playwright/test": "^1.25.2"
}
}
What on earth am I missing? Did a lot of Googling and still stuck.
Any help would be appreciated.
Base on my experience, npx command was not recognized as executable command.
I tried changing to npm playwright install and it worked.
enter image description here
So, I'm not sure what happened, but when I tried a new project and followed the same steps, everything worked fine.
I guess the takeaway is, if this happens, try re-installing ¯_(ツ)_/¯
I've got an issue when invoking other Yarn scripts from a Yarn-script. What I want to achieve is having one yarn develop task that first invokes TypeScript and some other preprocessors before starting a couple of watchers and running my application. I'd like to use npm-run-all (or something similar) to invoke multiple targets as that would allow me to define separate targets that I can manually run as well without having duplicate script-entries in my package.json.
I've made a minimal reproduction case which has the following package.json:
{
"name": "test",
"version": "1.0.0",
"main": "index.js",
"license": "MIT",
"scripts": {
"task:one": "echo one",
"task:two": "echo two",
"run-all": "npm-run-all task:one task:two",
"run-all-yarn": "yarn task:one && yarn task:two"
},
"devDependencies": {
"npm-run-all": "^4.1.5"
}
}
Invoking yarn task:one results in an echo one as expected, as does yarn task:two. If I invoke yarn run-all though, I get an error:
$-> yarn run-all
yarn run v1.22.10
$ npm-run-all task:one task:two
$ echo one
error Couldn't find the binary echo one
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
ERROR: "task:one" exited with 1.
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
yarn run-all-yarn fails with (almost exactly, sans the command being executed on the second line) the same error.
If instead of Yarn I use NPM (npm run run-all) it all works as expected:
$-> npm run run-all
> test#1.0.0 run-all /Users/basdalenoord/Projects/52DN/psyflix/test
> npm-run-all task:one task:two
> test#1.0.0 task:one /Users/basdalenoord/Projects/52DN/psyflix/test
> echo one
one
> test#1.0.0 task:two /Users/basdalenoord/Projects/52DN/psyflix/test
> echo two
two
I'm using Yarn version 1.22.17 provided by my node-version from nvm: ~/.nvm/versions/node/v14.18.1/bin/yarn
I'm a bit lost as to why running individual targets would be fine but combining them fails for yarn, whereas the same script works for npm.
I'm trying to make the jump to pnpm from npm. I found a helpful hint to keep from running "npm install" after I make the change as described here: https://pnpm.js.org/en/only-allow-pnpm
Unfortunately my preinstall lifecycle override doesn't get executed. Seems to simple enough but npm install still works when I run something like "npm install #types/jest"
package.json:
{
"name": "react-sandbox",
"version": "0.1.0",
"private": true,
"scripts": {
"preinstall": "npx only-allow pnpm"
}
}
npm version 6.14.2.
Any ideas?
Unfortunately, the preinstall script is executed only during argumentless installation. So when you run npm add #types/jest, that script will not be executed, thus npm won't be prevented from running.
But it will fail when running npm install.
As of now, there is no other way to prevent npm from execution.
If I follow this readme:
https://github.com/expo/expo/tree/master/packages/jest-expo
My output when running npm run test is this:
> apprepo#0.0.0 test C:\Users\[username]\Documents\Projects\[projectname]
> jest
PS C:\Users\[username]\Documents\Projects\[projectname]>
It just outputs nothing. I tried with yarn as well, but no luck.
I had the same issue and fixed it by changing the "test" scripts section
from:
"test": "node_modules/.bin/jest"
to:
"test": "node ./node_modules/jest/bin/jest.js"
It seems their GitHub how-to is incorrect.
If I run yarn add <dependency> -D, yarn will install the dependency AND run a task in my package.json. It'll run the "start" script.
At first I was annoyed so I renamed "start" with something else, but now it'll run "build" after the add command...
Is there a way to prevent yarn from running any command after add ?
Here's my current scripts in package.json :
"scripts": {
"clean": "mkdir -p lib && rm -r lib",
"build": "yarn clean && tsc",
"test": "tsc && mocha -c",
"test:watch": "tsc-then -- mocha -c"
}
note: I opened an issue for those who are interested, as it seems to be specific to watchy^0.9.0 #atom/watcher problem #20
You have the --ignore-scripts flag.
From yarn add --help:
--ignore-scripts don't run lifecycle scripts
yarn add --ignore-scripts -D package-name-1 ...
You can find this, and more with yarn add --help.
This is on Yarn 1.7.0.
I've been having this issue as well since I switched to Yarn over NPM. It appears that yarn, when given an unknown command, searches for one with the same name in your package.json scripts.
Additionally, for some reason yarn runs an excessive amount of additional lifecycle scripts on top of ones specified here on npm.
I had three scripts; build, update, and prepare. Renaming build to babel stopped that from being run. Renaming update to submodules stopped that. And renaming prepare to update-and-transpile stopped it.
So... just pick a more convoluted name for the time being and it stops being run.
I realize this isn't exactly an answer to your question, I'm going to file an issue on their GitHub about disabling this functionality.