I'm trying to make a discord bot with the command prefix "*" but when I try to get the bot online/run it, it gives me this error:
node:internal/modules/cjs/loader:936
node:internal/modules/cjs/loader:936 throw err; ^
Error: Cannot find module 'C:\Users\name\const'
at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)
at Function.Module._load (node:internal/modules/cjs/loader:778:27)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:79:12)
at node:internal/main/run_main_module:17:47 { code: 'MODULE_NOT_FOUND', requireStack: [] }
The module I'm using is discord.js and i've installed discord.js on CMD and the VSC terminal but it still comes up with the MODULE NOT FOUND error. I've looked around the internet and I can't find one that fixes the problem. I've tried reinstalling Node.js but it won't stop coming back. Please help, Thanks!
same error with me but I just change file dir cause I run node <filename.js> in the wrong dir so I just change like ---
the first step chacks you are in the right dir or not type: > ls
then if you are in the right dir then type: node <filename.js> if not then change your dir to change dir type: cd <filename>
and then run your first app or file for run type: node <filename.js>
I hope your error is solved!
you need to run it as an administrator so sudo(whatever you tryna run) as long as you are in the right directory
On Windows I solved it like this.
I went to the folder: C:\Users\Documents\AppData\Roaming\npm
And I deleted the file. create-react-app.
I started the project again, and it worked.
root cause, my path was messed up, but I only figured that out once I found where my npm packages where. I had thought they were in ../Programs/Roaming/npm etc but since an update (I think to node) my packages were actually in a Python Lib subdir.
Your Answer might be the same as mine, and I found out all this by using the
npm list -g
Command - which showed the globally installed packages, but also highlighted that this was nowhere to be found in my path
Hope this helps someone!
I had the same error and it was a case of trying to run the file in node from the wrong location.
My solution was to use the terminal and CD into the exact folder the file I was trying to run were and then after that I could run node filename.js.
In my case (this error ocurred at running docker container of next app), it was because I was running docker-compose without the flag --build, but of without copy lock files (package-lock.json and/or yarn.lock).
I updated my Dockerfile:
[...]
COPY yarn.lock .
RUN yarn install --frozen-lockfile
CMD [ "yarn", "dev" ]
And after, run with docker-compose up --build
When I was following a JS tutorial i got this error message too.
The problem was I copied an existing JS file and renamed it but it
through that error when i ran it.
When i created a new JS file, and copied the code in, and ran, it worked.
Before starting your server you need to make sure that the start file is mentioned below
cross-env NODE_ENV=production node index<start file name eg:index for index.js>
It happens when you run npm run start without getting into the project first... So, before starting to compile your project, run this command: cd <project folder name>...
It will stop showing the "Missing Module" Error and smoothly run your desired output in your browser
When was trying to find 'npm' & 'Rdme' path from command prompt to update the Rdme was getting this error Log
This error is caused when file can't be found or its a wrong path, In my case I added the missing file to respective folders- configured & updated in Environment variables (after adding missing files)
For the coming next. For me I'v got the error when I tried to run a package.json script with the npx run rather npm run.
In my case, I used chocolatey to install nodejs and it fixed my issue.
Open an Administrator Command Prompt (right click Command Prompt and select "Run as Administrator"), then run the following command:
choco install -y nodejs-lts
I hope it works for you too :)
The error tells that you've required packages that you haven't installed. So please make sure that you've installed every package that you've required in your bot. Also if you're sure that you've installed it, please check it again, there were namely some problems for some people that some of their packages got uninstalled while updating Discord.js to version 13.
For your problem in the comments ("TypeError [CLIENT_MISSING_INTENTS]"), it is now required in Discord.js version 13 to add your needed intents in the client. Please read this part of the Discord.js guide.
I fixed this issue by changing the opened directory of the terminal. Just go to the terminal and type: cd <folder name> until you reach the folder in which your js file is located. Then save and run again.
npm uninstall webpack-cli -D
npm install webpack-cli#3.3.12 --save-dev
than work fine
I was trying to change my npm and npm-cache folders to d:\\npm-global and d:\\npm-cache
I managed to do a npm config set cache d:\npm-cache
When I tried to do a npm config set prefix d:\npm-global I accidentally put a ' in the folder string as I was hitting enter. I deleted the errant folder after trying a npm i -g gulp and to my horror, npm stopped working altogether, it just sits there with my command prompt rocking up to 50% CPU usage.
Help please! I've tried searching the registry and other places, even uninstalled and re-installed the nodejs msi package on Windows. This reset the D:\Program Files\nodejs\node_modules\npm\npmrc file.
Still no luck. I can't get npm to work again. :(
edit A little digging in and I realized there is a second node server running via Adobe Creative Cloud. I doubt this is the problem though as when I run npm from the cmd.exe prompt, the correct (d:\program files\nodejs) version of the npm server is executed for that process.
edit so only sometimes when I hit Control-C, I'll get this error:
seems like it's trying to find a file that doesn't exist. However, I cleared out the AppData\Roaming\npm folder and the reinstalls reset the default d:\program files\nodejs\....npm\npmrc file. I also made sure that the environment variable NODE_PATH is not set. It wasn't set when it was working. I set it when I was trying to make my changes.
You should be able to modify your config settings manually by modifying ~/.npmrc
#jakemingolla was right so I marked that answer as accepted (thanks Jake), but I also asked this in the NPM forum and did a little test after I got it working. I thought this might help someone: https://npm.community/t/i-killed-my-npm-on-windows-trying-to-move-some-folders-reinstalling-nodejs-isnt-resetting-the-problem/5743/8?u=chi11ax
I just installed meteor on my Windows 10 system and tried to start an existing Meteor project by running meteor in the root of the project directory.
This gives an error
C:\Users\test\AppData\Local\.meteor\packages\meteor-tool\1.4.2\mt-os.windows.x86_32\dev_bundle\lib\node_modules\meteor-promise\promise_server.js:190
throw error;
^
Error: EPERM: operation not permitted, unlink 'C:\Users\test\test-meteor-project\.meteor\local\dev_bundle'
at Error (native)
at Object.fs.unlinkSync (fs.js:932:18)
at exports.makeLink (C:\tools\cli\dev-bundle-links.js:20:8)
at [object Object].ensureDevBundleLink (C:\tools\project-context.js:1444:7)
at [object Object]._readFile (C:\tools\project-context.js:1378:10)
at new exports.ReleaseFile (C:\tools\project-context.js:1328:8)
at C:\tools\cli\main.js:869:22
Running meteor reset gives the same error! What can we do to solve this?
For anyone else who stumbles across this same issue.
The problem I had was that in the directory where I was tyring to create a new meteor project, there already existed a .meteor folder. (Probably from an earlier failed attempt).
E.g. In the folder Meteor I was trying to create meteor project three
-Meteor
--.meteor
--project one
--project two
The solution was simply to delete the .meteor folder.
Another thing to try is running the cmd window with admin rights.
I've written up this and other Meteor fixes here:
http://blacksandsolutions.azurewebsites.net/blog/meteorjs-on-windows-10-2/
Try deleting your yourApp.meteor\local folder
I solve this problem just make a symbolic link.
If someone has this problem, just make a symbolic link dev_bundle in '.meteor\packages\meteor-tool\1.4.2\mt-os.windows.x86_32\dev_bundle'
I think that this is the problem your dev_bundle in meteor project unlink to dev_bundle
I am stuck with this error no matter what directory I am in, and what I type after "npm" in cmd.exe. Here is the npm-debug.log:
0 info it worked if it ends with ok
1 verbose cli [ 'C:\\Program Files\\nodejs\\node.exe',
1 verbose cli 'C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js' ]
2 info using npm#2.14.12
3 info using node#v4.2.6
4 verbose stack Error: EISDIR: illegal operation on a directory, read
4 verbose stack at Error (native)
5 verbose cwd C:\Users\me
6 error Windows_NT 6.1.7601
7 error argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js"
8 error node v4.2.6
9 error npm v2.14.12
10 error code EISDIR
11 error errno -4068
12 error syscall read
13 error eisdir EISDIR: illegal operation on a directory, read
13 error eisdir This is most likely not a problem with npm itself
13 error eisdir and is related to npm not being able to find a package.json in
13 error eisdir a package you are trying to install.
14 verbose exit [ -4068, true ]
I have tried and uninstalling/reinstalling nodejs multiple times, I even deleted npm and npm-cache folders in C:\Users\me\AppData\Roaming. I'm not sure what went wrong to cause this. One second it was working fine, and now I can't get rid of this error. The explanation in the log does not make sense, as it gives this error in any directory. I should note that running a command prompt as administrator does not give this error. I'm pulling my hair out this Friday evening trying to get this fixed, any help would be greatly appreciated!
EISDIR stands for "Error, Is Directory". This means that NPM is trying to do something to a file but it is a directory. In your case, NPM is trying to "read" a file which is a directory (Line: 4). Since the operation cannot be done the error is thrown.
Three things to make sure here.
Make sure the file exists. If it does not, you need to create it. (If NPM depends on any specific information in the file, you will need to have that information there).
Make sure it is in fact a file and not a directory.
It has the right permissions. You can change the file to have all permissions with "sudo chmod 777 FILE_NAME". (Careful: You are giving Read, Write and Execute permissions to every one on that file)
I ran into the same problem while I was changing some npm settings. I did a mistake with one npm config set command and this added a line referring to a non-existing directory to C:\Users\{User}\.npmrc. After I deleted that line manually from .npmrc, the problem was gone.
In my case I was getting the "EISDIR: illegal operation on a directory, read" because in my .angular-cli.json file I wasn't providing a full path in "scripts:"
For example I had
"scripts": [
"../node_modules/hammerjs",
"../node_modules/moment"
],
In fact it should have been
"scripts": [
"../node_modules/hammerjs/hammer.min.js",
"../node_modules/moment/min/moment.min.js"
],
Had the same problem today after i've upgraded my npm from version 6.4.1 to version 6.5.0. I fixed this by downloading the .pkg installer (recommended for most users) from node.js and runned it afterwards.
I had the same issue on Mac OS X (installed with homebrew), and the .npmrc is not the only place node stored config variables. There is a glocal npmrc config file in /usr/local/etc that you have to edit using this command:
sudo nano npmrc
Remove the ca= line, or whatever the config setting was that broke your install, save that file, and try npm again, and you should see it working.
These strange errors occured recently on my OSX machine.
I could help myself the quick & dirty way by running:
sudo chmod -R 777 /usr/local/lib/node_modules/
Something seemed to have messed up the access rights of all global node modules.
For me it was because I was using the the wrong path; it should have been a path to a file yet I was wrongly using a path to a directory:
Changed this:
path.resolve(__dirname, '../');
Into this:
path.resolve(__dirname, '../.env')
So most of the answers were saying it was related to the .npmrc file.
In my case, I was deploying a serverless application using serverless deploy and the message
EISDIR: illegal operation on a directory, unlink '/home/malvadao/workspace/project/.build/node_modules'
was being thrown.
Deleting the .build folder did it for me. It was the folder generated after Typescript compilation. Since the folder is recreated after launching the serverless deploy command, it was enough to solve the problem and continue the flow.
In other words, manually deleting the folder might be enough for you to move forward, without the need to touch .npmrc
If your problem is associated with the React Native packager. Try resetting the cache with react-native start --reset-cache.
For me fixing was add slash after directory name
Make sure node_modules (and your root package.json) doesn't contain a reference to npm's "package.json" module. Deleting package.json FOLDER from node_modules solved the issue for me.
Just delete .npmrc folder in c:users>'username' and try running the command it will be resolved !
Doing a complete uninstall, including removing paths, etc and reinstalling has solved the problem, very strange problem though.
How to completely remove node.js from Windows
I had this issue with gulp. The problem was that gulp added a dependency to my source file and I think npm tried to open it:
{
"name": "name",
"version": "2.0.0",
"description": "",
"main": "gulpfile.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"devDependencies": {
"appname": "file://gulp",
"gulp-concat": "^2.6.1",
"gulp-electron": "^0.1.3",
"gulp-shell": "^0.5.2",
"gulp-uglify": "^2.0.0",
"gulp-util": "^3.0.7",
"node-7z": "^0.4.0"
}
}
Make sure that there are no strange references in you package.json file.
Check to ensure you are running npm install from the proper directory.
(The package.json file could be one extra directory down, for example.)
Had the same problem until I tried deleting the .git folder. It worked. I guess this type of problem can have different causes.
In my case I forgot to pass the full path of one of the file it was asking. After passing full path of the file worked :)
In my case, i was facing this issue while installing create-react-app in MAC (Mojave OS) with following command :
sudo npm install create-react-app -g
and got errors like this :
npm WARN tar EISDIR: illegal operation on a directory, open '/usr/local/lib/node_modules/.staging/rxjs-a84420a7/src/scheduler'
npm WARN tar EISDIR: illegal operation on a directory, open '/usr/local/lib/node_modules/.staging/rxjs-a84420a7/src/symbol'
npm WARN tar EISDIR: illegal operation on a directory, open '/usr/local/lib/node_modules/.staging/rxjs-a84420a7/src/testing'
npm WARN tar EISDIR: illegal operation on a directory, open '/usr/local/lib/node_modules/.staging/rxjs-a84420a7/src/util'
npm WARN tar EISDIR: illegal operation on a directory, open '/usr/local/lib/node_modules/.staging/rxjs-a84420a7/src/webSocket'
npm WARN tar EISDIR: illegal operation on a directory, open '/usr/local/lib/node_modules/.staging/rxjs-a84420a7/symbol'
npm WARN tar EISDIR: illegal operation on a directory, open '/usr/local/lib/node_modules/.staging/rxjs-a84420a7/testing'
npm WARN tar EISDIR: illegal operation on a directory, open '/usr/local/lib/node_modules/.staging/rxjs-a84420a7/util'
npm WARN tar EISDIR: illegal operation on a directory, open '/usr/local/lib/node_modules/.staging/rxjs-a84420a7/webSocket'
I have read npm.community that try to install without sudo :
npm install create-react-app -g
and it actually solved my issue ..!!
I had the same problem.
Recently just deleted the .npmrc file in the user directory and afterwards, I ran npm init -y
Works!
In my case, my fault was assuming, that script allow to work with directories, but it waited FILE PATH, so try to set full path to file.
In my case was:
['/var/task/myFolder']
but right path should be :
['/var/task/myFolder/sample.tgs']
Project related to chromium usage inside puppeteer on serverless was lambda. Hope, it helps.
I had a similar problem while setting up boilerplate code. It was reading my bundle.js file as a directory. So as stated here. EISDIR mean its a directory and not a file. To fix the issue, I deleted the file and just recreated (it was originally created automatically).
If you cannot find the file (because its hidden), simply use the terminal to find and delete it.
I had the same issue. There was a linked folder in my directory which was causing the issue. i added that folder to ignore list and then it started working fine as expected.
I know this isn't specifically asking about forever js.. but google lead me here so.. For me it was as simple as an ending slash.
I just changed:
forever start -a -l /dev/null/ /var/www/node/my_file.js
To:
forever start -a -l /dev/null /var/www/node/my_file.js
And the error disappeared
Make sure to check your version of npm and whether or not there are issues with it. I was having the same issue at the time of this post and I discovered that my npm version (6.5) was having issues. I had to uninstall and reinstall npm version 6.4.1 and then everything started to work great again.
I had a broken symlink to node_modules in a subfolder
In my case, I'm using Windows 10 in Spanish and this version mixes English and Spanish directory names. My problem was that the desktop directory has this name for some commands and escritorio to others. I believe that npm cannot resolve this. My solution was to simply change to another directory starting from C:\ different to my home directory.
I had faced similar issue. I set cafile using the command:
npm config set cafile PATH_TO_CERTIFICATE
I was able to resolve this by deleting the certificate file settings, and setting strict-ssl = false.
I fixed this issue by moving my directory from my exFAT drive which does not support symlinking.
My exFat drive is shared between osx and a bootcamp windows partition so when I tried to clone and npm install my project it was failing but never explains that exFAT doesn't support this functionality.
There are drivers out there that you can install to add the ability to symlink but you'll have to do a lot of your setup manually compared to running a simple npm script.
For mac os:
If installed directly from nodejs website the npmrc file would be located in /usr/local/etc/npmrc. Just delete the config which is undefined and this problem would be fixed.
In my case, the C:\Users\{user}\AppData\local\npm files were hidden, so I was not able to find & delete the trouble directory. Took me DAYS to realize this!
So double check to un-hide any folders so you don't miss them! Here's a link to do this if you don't know how.