Npm install creates the nodemodules file but once completed it disappears i have posted the log below

i am facing this issue, when i run “npm install”. it creates the nodemodules file and then it disappears. which then causes

mflix-js % npm start                   

> server@1.0.0 start
> nodemon -L ./index.js

sh: nodemon: command not found

the below lines are the log:

4919 silly reify   '/Users/kevindsa/Documents/mongodb university/mflix-js/node_modules/fsevents/node_modules/is-fullwidth-code-point'
4919 silly reify ]
4920 verbose reify failed optional dependency /Users/kevindsa/Documents/mongodb university/mflix-js/node_modules/fsevents/node_modules/ansi-regex
4921 silly reify mark deleted [
4921 silly reify   '/Users/kevindsa/Documents/mongodb university/mflix-js/node_modules/fsevents/node_modules/ansi-regex'
4921 silly reify ]
4922 verbose reify failed optional dependency /Users/kevindsa/Documents/mongodb university/mflix-js/node_modules/fsevents/node_modules/wrappy
4923 silly reify mark deleted [
4923 silly reify   '/Users/kevindsa/Documents/mongodb university/mflix-js/node_modules/fsevents/node_modules/wrappy'
4923 silly reify ]
4924 verbose reify failed optional dependency /Users/kevindsa/Documents/mongodb university/mflix-js/node_modules/fsevents/node_modules/balanced-match
4925 silly reify mark deleted [
4925 silly reify   '/Users/kevindsa/Documents/mongodb university/mflix-js/node_modules/fsevents/node_modules/balanced-match'
4925 silly reify ]
4926 verbose reify failed optional dependency /Users/kevindsa/Documents/mongodb university/mflix-js/node_modules/fsevents/node_modules/concat-map
4927 silly reify mark deleted [
4927 silly reify   '/Users/kevindsa/Documents/mongodb university/mflix-js/node_modules/fsevents/node_modules/concat-map'
4927 silly reify ]
4928 verbose reify failed optional dependency /Users/kevindsa/Documents/mongodb university/mflix-js/node_modules/fsevents/node_modules/number-is-nan
4929 silly reify mark deleted [
4929 silly reify   '/Users/kevindsa/Documents/mongodb university/mflix-js/node_modules/fsevents/node_modules/number-is-nan'
4929 silly reify ]
4930 timing build:run:install:node_modules/fsevents Completed in 1369ms
4931 timing reify:rollback:createSparse Completed in 3857ms
4932 timing reify:rollback:retireShallow Completed in 0ms
4933 timing command:i Completed in 20570ms
4934 verbose stack Error: command failed
4934 verbose stack     at ChildProcess.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/@npmcli/promise-spawn/index.js:64:27)
4934 verbose stack     at ChildProcess.emit (node:events:520:28)
4934 verbose stack     at maybeClose (node:internal/child_process:1092:16)
4934 verbose stack     at Process.ChildProcess._handle.onexit (node:internal/child_process:302:5)
4935 verbose pkgid weak-napi@1.0.3
4936 verbose cwd /Users/kevindsa/Documents/mongodb university/mflix-js
4937 verbose Darwin 21.6.0
4938 verbose argv "/usr/local/bin/node" "/usr/local/bin/npm" "i"
4939 verbose node v16.14.0
4940 verbose npm  v8.3.1
4941 error code 1
4942 error path /Users/kevindsa/Documents/mongodb university/mflix-js/node_modules/weak-napi
4943 error command failed
4944 error command sh -c node-gyp rebuild
4945 error CC(target) Release/obj.target/nothing/../node-addon-api/src/nothing.o
4945 error   LIBTOOL-STATIC Release/nothing.a
4945 error   CXX(target) Release/obj.target/weakref/src/weakref.o
4946 error gyp info it worked if it ends with ok
4946 error gyp info using node-gyp@8.4.1
4946 error gyp info using node@16.14.0 | darwin | arm64
4946 error gyp info find Python using Python version 3.9.6 found at "/Library/Developer/CommandLineTools/usr/bin/python3"
4946 error gyp info spawn /Library/Developer/CommandLineTools/usr/bin/python3
4946 error gyp info spawn args [
4946 error gyp info spawn args   '/usr/local/lib/node_modules/npm/node_modules/node-gyp/gyp/gyp_main.py',
4946 error gyp info spawn args   'binding.gyp',
4946 error gyp info spawn args   '-f',
4946 error gyp info spawn args   'make',
4946 error gyp info spawn args   '-I',
4946 error gyp info spawn args   '/Users/kevindsa/Documents/mongodb university/mflix-js/node_modules/weak-napi/build/config.gypi',
4946 error gyp info spawn args   '-I',
4946 error gyp info spawn args   '/usr/local/lib/node_modules/npm/node_modules/node-gyp/addon.gypi',
4946 error gyp info spawn args   '-I',
4946 error gyp info spawn args   '/Users/kevindsa/Library/Caches/node-gyp/16.14.0/include/node/common.gypi',
4946 error gyp info spawn args   '-Dlibrary=shared_library',
4946 error gyp info spawn args   '-Dvisibility=default',
4946 error gyp info spawn args   '-Dnode_root_dir=/Users/kevindsa/Library/Caches/node-gyp/16.14.0',
4946 error gyp info spawn args   '-Dnode_gyp_dir=/usr/local/lib/node_modules/npm/node_modules/node-gyp',
4946 error gyp info spawn args   '-Dnode_lib_file=/Users/kevindsa/Library/Caches/node-gyp/16.14.0/<(target_arch)/node.lib',
4946 error gyp info spawn args   '-Dmodule_root_dir=/Users/kevindsa/Documents/mongodb university/mflix-js/node_modules/weak-napi',
4946 error gyp info spawn args   '-Dnode_engine=v8',
4946 error gyp info spawn args   '--depth=.',
4946 error gyp info spawn args   '--no-parallel',
4946 error gyp info spawn args   '--generator-output',
4946 error gyp info spawn args   'build',
4946 error gyp info spawn args   '-Goutput_dir=.'
4946 error gyp info spawn args ]
4946 error gyp info spawn make
4946 error gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ]
4946 error warning: /Library/Developer/CommandLineTools/usr/bin/libtool: archive library: Release/nothing.a the table of contents is empty (no object file members in the library define global symbols)
4946 error clang: error: no such file or directory: 'university/mflix-js/node_modules/node-addon-api'
4946 error make: *** [Release/obj.target/weakref/src/weakref.o] Error 1
4946 error gyp ERR! build error 
4946 error gyp ERR! stack Error: `make` failed with exit code: 2
4946 error gyp ERR! stack     at ChildProcess.onExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:194:23)
4946 error gyp ERR! stack     at ChildProcess.emit (node:events:520:28)
4946 error gyp ERR! stack     at Process.ChildProcess._handle.onexit (node:internal/child_process:291:12)
4946 error gyp ERR! System Darwin 21.6.0
4946 error gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
4946 error gyp ERR! cwd /Users/kevindsa/Documents/mongodb university/mflix-js/node_modules/weak-napi
4946 error gyp ERR! node -v v16.14.0
4946 error gyp ERR! node-gyp -v v8.4.1
4946 error gyp ERR! not ok
4947 verbose exit 1
4948 timing npm Completed in 20696ms
4949 verbose unfinished npm timer reify 1665677022881
4950 verbose unfinished npm timer reify:build 1665677038649
4951 verbose unfinished npm timer build 1665677038652
4952 verbose unfinished npm timer build:deps 1665677038653
4953 verbose unfinished npm timer build:run:install 1665677038707
4954 verbose unfinished npm timer build:run:install:node_modules/weak-napi 1665677038729
4955 verbose code 1
4956 error A complete log of this run can be found in:
4956 error     /Users/kevindsa/.npm/_logs/2022-10-13T16_03_42_757Z-debug-0.log

Hi @kevin_dsa, welcome to the community.
Do you have a file called package-lock.json in your mflix-js folder? If so, can you please delete package-lock.json along with the node_modules and reinstall the dependency with the legacy peer deps flag as well like this:

npm install --legacy-peer-deps

If you have any doubts, please feel free to reach out to us.

Thanks and Regards.
Sourabh Bagrecha,
MongoDB

2 Likes

Thank you @SourabhBagrecha this solved my issue