At Beginning, I try npm i
to install packages, error:
npm ERR! code ENOTDIR
npm ERR! syscall mkdir
npm ERR! path my_project_foldernode_modules
npm ERR! errno -4052
npm ERR! ENOTDIR: not a directory, mkdir 'my_project_foldernode_modules'
I don’t know why it cannot automatically generate the node_modules folder?
To fix this bug, I manually made the node_modules folder, and try ‘npm i’, it seems successfully:
added 2 packages, and audited 3 packages in 9s
found 0 vulnerabilities
but when I run node server.js
, another bug:
node:internal/modules/cjs/loader:998
throw err;
^
Error: Cannot find module 'dayjs'
But when I rum npm list
, it shows:
[email protected] my_project_folder
├── [email protected]
└── [email protected]
package.json
is under the my_project_folder (the root folder)
server.js
is under the my_project_folder (the root folder)
in package.json
, I use "type": "CommonJS"
, and in server.js
, I use const dayjs = require('dayjs')
I really want to understand what is going on here, but I’m at a bit of a loss as to where to look next. Any suggestions?
2