-
Notifications
You must be signed in to change notification settings - Fork 3k
npm just deleted my all files from node_modules #19450
Comments
Can you provide reproduction steps? |
Possibly a duplicate of #16853. |
here is a test case (copy then paste to a terminal) npm -v
mkdir test
cd test
# test passes:
mkdir install_normal_module__without_save_then_install_another_module
cd install_normal_module__without_save_then_install_another_module/
npm init -y
echo "console.log('test')">index.js
npm install underscore
ls node_modules/ # the module is there.
npm install lodash --save
ls node_modules/ # the module is still there, ok.
cd ..
# test passes:
mkdir install_and_modify_normal_module_then_install_another_module
cd install_and_modify_normal_module_then_install_another_module/
npm init -y
echo "console.log('test')">index.js
npm install underscore --save
tail -n 1 node_modules/underscore/underscore.js # see no cahnges yet
echo "//modification" >> node_modules/underscore/underscore.js
tail -n 2 node_modules/underscore/underscore.js # the changes are there
npm install lodash --save
tail -n 2 node_modules/underscore/underscore.js # see changes to node_modules/underscore/underscore.js preserved as expected
cd ..
#test fails:
mkdir install_github_module_then_install_another_module
cd install_github_module_then_install_another_module/
npm init -y
npm install shimondoodkin/chrome-headless-render-pdf --save
ls node_modules/ # the module is there. there are many modules.
npm install lodash --save
ls node_modules/ # folder chrome-headless-render-pdf is removed totally, even not reinstalled as supposed to. also removed all related modules.
cat package.json # still has entry for shimondoodkin/chrome-headless-render-pdf
cd ..
#test fails:
mkdir install_and_modify_github_module_then_install_another_module
cd install_and_modify_github_module_then_install_another_module/
npm init -y
echo "console.log('test')">index.js
npm install shimondoodkin/chrome-headless-render-pdf --save
tail -n 1 node_modules/chrome-headless-render-pdf/index.js
echo "//modification" >> node_modules/chrome-headless-render-pdf/index.js
tail -n 2 node_modules/chrome-headless-render-pdf/index.js
ls node_modules/
npm install lodash --save
ls node_modules/ # folder chrome-headless-render-pdf is removed totally, even not reinstalled as supposed to be
cat package.json # still has entry for shimondoodkin/chrome-headless-render-pdf
tail -n 2 node_modules/chrome-headless-render-pdf/index.js # expected to see here '// modification', nothing to see, file missing
cd ..
#test fails:
mkdir create_new_module_then_install_another_module
cd create_new_module_then_install_another_module/
npm init -y
echo "console.log('test')">index.js
mkdir -p node_modules/newmodule
cd node_modules/newmodule/
npm init -y
echo "console.log('new module')">index.js
cd ../..
ls node_modules/ # newmodule is there
npm install lodash --save
ls node_modules/ # the folder newmodule is removed,
cd ..
cd ..
rm ./test -rf output:
|
expected behavior "
recently npm to me feels very shaky and unstable not sure why maybe many options have been developed and all the combinations of options usages times usage sequences are not tested. |
@shimondoodkin i think the bug is on user side in this case you don't edited your package.json before running npm install maybe also mixed up lock file. i verified it if you install and save dependencies all gets honored right |
@frank-dspeed not sure what you mean. When you run #test fails: |
This is a duplicate of #16853 |
I use yarn instead of npm to avoid this |
npm should not delete by itself files when installing new module. just install a new module
The text was updated successfully, but these errors were encountered: