Describe the bug
Error with the prettier dependency while running the lint script from @wordpress/scripts after a new npm install.
To reproduce
Steps to reproduce the behavior:
- Create a project and add the
@wordpress/scripts dev dependency
> mkdir scripts-test \
&& cd scripts-test \
&& npm init -y && npm i -D @wordpress/scripts
- Add the script to the package.json:
"lint:js": "wp-scripts lint-js"
- Create a js file and run the lint to see it is working.
> echo 'const x = 1;' >index.js \
&& npm run lint:js
- Checking the prettier dependency in this moment:
> npm ls prettier
scripts-test@1.0.0 /Users/renatho/Downloads/scripts-test
└─┬ @wordpress/scripts@7.1.3
├─┬ @wordpress/eslint-plugin@4.0.0
│ └── prettier@npm:wp-prettier@1.19.1 deduped
└── prettier@npm:wp-prettier@1.19.1
- You can make a
git init here and commit the package-lock to see the next changes.
- Remove the
node_modules folder, reinstall the packages and run the lint script. The new install will update (unexpectedly) our package-lock.json and It stops to work because it doesn't find the prettier. You will see the error Error: Cannot find module 'prettier'
> rm -rf node_modules \
&& npm i \
&& npm run lint:js
- Check the prettier dependency to understand what happened (you can also see the
package-lock diff):
> npm ls prettier
scripts-test@1.0.0 /Users/renatho/Downloads/scripts-test
└─┬ @wordpress/scripts@7.1.3
├─┬ @wordpress/eslint-plugin@4.0.0
│ └── UNMET PEER DEPENDENCY prettier@npm:wp-prettier@1.19.1
└── prettier@npm:wp-prettier@1.19.1
Expected behavior
Install the @wordpress/scripts and after other npm install it continues to work properly while running the npm run lint:js.
Version (please complete the following information):
- A clean project with only the
@wordpress/scripts installed. Reproduced in 7.1.3 and 8.0.1
Desktop (please complete the following information):
- OS: macOS Catalina
- NPM 6.14.4 / Node 10.17.0
Describe the bug
Error with the
prettierdependency while running the lint script from@wordpress/scriptsafter a newnpm install.To reproduce
Steps to reproduce the behavior:
@wordpress/scriptsdev dependency"lint:js": "wp-scripts lint-js"git inithere and commit thepackage-lockto see the next changes.node_modulesfolder, reinstall the packages and run the lint script. The new install will update (unexpectedly) ourpackage-lock.jsonand It stops to work because it doesn't find theprettier. You will see the errorError: Cannot find module 'prettier'package-lockdiff):Expected behavior
Install the
@wordpress/scriptsand after othernpm installit continues to work properly while running thenpm run lint:js.Version (please complete the following information):
@wordpress/scriptsinstalled. Reproduced in7.1.3and8.0.1Desktop (please complete the following information):