Skip to content
This repository has been archived by the owner on Aug 11, 2022. It is now read-only.

npm v5: npm install-test runs test lifecycle twice when package-lock is false. #16940

Open
ljharb opened this issue Jun 3, 2017 · 2 comments
Labels

Comments

@ljharb
Copy link
Contributor

ljharb commented Jun 3, 2017

As I hinted in #16843, npm install-test runs pretest twice.

The following package.json:

{
	"name": "test",
	"scripts": {
		"foo": "echo foo",
		"pretest": "npm run foo && echo pretest",
		"test": "npm run foo && echo test",
		"posttest": "npm run foo && echo posttest"
	}
}

produces the following (correct) output with npm it:

npm notice created a lockfile as package-lock.json. You should commit this file.
npm WARN test@ No description
npm WARN test@ No repository field.
npm WARN test@ No license field.

up to date in 0.113s

> test@ pretest $HOME/tmp
> npm run foo && echo pretest


> test@ foo $HOME/tmp
> echo foo

foo
pretest

> test@ test $HOME/tmp
> npm run foo && echo test


> test@ foo $HOME/tmp
> echo foo

foo
test

> test@ posttest $HOME/tmp
> npm run foo && echo posttest


> test@ foo $HOME/tmp
> echo foo

foo
posttest

but produces the following (incorrect) output with npm it --no-package-lock:

npm WARN test@ No description
npm WARN test@ No repository field.
npm WARN test@ No license field.

up to date in 0.093s

> test@ pretest $HOME/tmp
> npm run foo && echo pretest


up to date in 0.12s

> test@ foo $HOME/tmp
> echo foo

foo
pretest
npm notice created a lockfile as package-lock.json. You should commit this file.
npm WARN test@ No description
npm WARN test@ No repository field.
npm WARN test@ No license field.

> test@ pretest $HOME/tmp
> npm run foo && echo pretest


> test@ foo $HOME/tmp
> echo foo

foo
pretest

> test@ test $HOME/tmp
> npm run foo && echo test


> test@ foo $HOME/tmp
> echo foo

foo
test

> test@ test $HOME/tmp
> npm run foo && echo test


> test@ foo $HOME/tmp
> echo foo

foo
test

> test@ posttest $HOME/tmp
> npm run foo && echo posttest


> test@ foo $HOME/tmp
> echo foo

foo
posttest

> test@ posttest $HOME/tmp
> npm run foo && echo posttest

[shell prompt]$
> test@ foo $HOME/tmp
> echo foo

foo
posttest

This probably overlaps with #16843 (since the second example incorrectly creates package-lock.json) but I thought it was worth filing separately.

Also, please note - the shell prompt ([shell prompt]$) appears before the final output, indicating that something is being backgrounded but not waited on.

@ljharb
Copy link
Contributor Author

ljharb commented Jun 17, 2017

(ping, just because i have no idea when npmbot might annihilate my issue)

@jakeNiemiec
Copy link

i have no idea when npmbot might annihilate my issue

@ljharb You mean the bot that closes issues due to lack of activity?...I guess now we need to bump issues like forum posts. ¯\(ツ)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants