Node.js are not running - javascript

Using macOs High Sierra, trying to run small node.js code node server.js, from iTerm, showing this error:
module.js:545
throw err;
^
Error: Cannot find module '/Users/vikasenkova/server.js'
at Function.Module._resolveFilename (module.js:543:15)
at Function.Module._load (module.js:470:25)
at Function.Module.runMain (module.js:690:10)
at startup (bootstrap_node.js:194:16)
at bootstrap_node.js:666:3
Cant't find solution here.. if somebody knows..Found this link https://gist.github.com/DanHerbert/9520689 when trying to delete files with this: rm -rf /usr/local/lib/node_modules showing that permission denied. Nothing helps.

Check if your running in the same directory as the server.js file. Also update your question with some code to get more specific answer. Hope it helps you.

Related

Apollo-server tutorial from GraphQL website produce error

I can't get this tutorial to work (running on Ubuntu v19.04):
https://www.apollographql.com/docs/apollo-server/getting-started/
My code is literally copy+pasted from the tutorial - I have installed all dependencies, and I keep getting the following error when running node index.js:
internal/modules/cjs/loader.js:628
throw e;
^
Error: No valid exports main found for '{project-path}/node_modules/uuid'
at resolveExportsTarget (internal/modules/cjs/loader.js:625:9)
at applyExports (internal/modules/cjs/loader.js:502:14)
at resolveExports (internal/modules/cjs/loader.js:551:12)
at Function.Module._findPath (internal/modules/cjs/loader.js:657:22)
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:960:27)
at Function.Module._load (internal/modules/cjs/loader.js:855:27)
at Module.require (internal/modules/cjs/loader.js:1033:19)
at require (internal/modules/cjs/helpers.js:72:18)
at Object.<anonymous> ({project-path}/project-myra/node_modules/apollo-engine-reporting/dist/agent.js:26:16)
at Module._compile (internal/modules/cjs/loader.js:1144:30) {
code: 'MODULE_NOT_FOUND'
This is literally so frustrating, because the only place to get any help with apollo-server is from a Spectrum chat that keeps disconnecting, and doesn't even allow me to create any posts...
Why is this library the official supported and recommended library for GraphQL? And how come I seem to be the only person in the world having this issue, I can't find anyone else asking about this...
It seems it's a problem with the current Apollo Server version.
Try downgrading to 2.6.3, this worked for me. Haven't tried with any other version though.
npm install apollo-server#2.6.3

Problems with cmd.exe and start.batch

So I am trying to start a discord bot but it won't allow me to acess the start.batch file, it just says this. I am currently learning so I dont exactly what it means
I've ran as administrator, not many things I just need some help
C:\WINDOWS\system32>node bot.js
internal/modules/cjs/loader.js:584
throw err;
^
Error: Cannot find module 'C:\WINDOWS\system32\bot.js'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:582:15)
at Function.Module._load (internal/modules/cjs/loader.js:508:25)
at Function.Module.runMain (internal/modules/cjs/loader.js:754:12)
at startup (internal/bootstrap/node.js:283:19)
at bootstrapNodeJSCore (internal/bootstrap/node.js:622:3)
C:\WINDOWS\system32>pause
Press any key to continue . . .`enter code here`
I would just like for my bot to work and for it to start because this is the only thing that will allow me to get my bot online.
Thanks
You should change directory to the root folder where your bot.js is located.

react-native-fetch-blob link FAILED

How can i Fix my error. i need to display a pdf from my assets folder. im using expo, react native, react-native-pdf
Scanning folders for symlinks in C:\Users\kjdelacruz\mobile\cdo-mobile-organizer\node_modules (31ms)
RNFetchBlob checking app version ..
RNFetchBlob detected app version => 6
Add Android permissions => false
react-native-fetch-blob link FAILED
Could not automatically link package :TypeError: path must be a string or Buffer
at Object.fs.readFile (fs.js:358:11)
at Object.<anonymous> (C:\Users\kjdelacruz\mobile\cdo-mobile-organizer\node_modules\react-native-fetch-blob\scripts\prelink.js:29:8)
at Module._compile (module.js:569:30)
at Object.Module._extensions..js (module.js:580:10)
at Module.load (module.js:503:32)
at tryModuleLoad (module.js:466:12)
at Function.Module._load (module.js:458:3)
at Function.Module.runMain (module.js:605:10)
at startup (bootstrap_node.js:158:16)
at bootstrap_node.js:575:3please follow the instructions to manually link the library : https://github.com/wkh237/react-native-fetch-blob/wiki/Manually-Link-Package
rnpm-install info Linking assets to ios project
rnpm-install ERR! Something went wrong while linking. Error: Cannot read property 'pbxprojPath' of null
Please file an issue here: https://github.com/facebook/react-native/issues
Cannot read property 'pbxprojPath' of null
Apparently rn-fetch-blob is incompatible with expo. I have dealt with this very problem before with expo and rn-fetch-blob.
"It doesn't work with Expo because Expo doesn't support native module linking. Like you said you'll have to detach from Expo in order to run react-native link react-native-fetch-blob for this to work."
https://docs.expo.io/versions/latest/guides/detach.html
You will need to use XCode to get it working.
There are a couple threads discussing. No solutions with expo though.
https://github.com/joltup/rn-fetch-blob/issues/97
https://github.com/wkh237/react-native-fetch-blob/issues/371

Unable to preview / run angular.js project from codenvy

I developed an angular.js project on codenvy IDE on Javascript framework ( or is it platform). I am unable to preview the same.
I get the following error.
[ERROR] Failed to start application. : ====> /logs/stderr.log <==== node.js:134 throw e; // process.nextTick error, or 'error' event on first tick ^ Error: Cannot find module 'gulp' at Function._resolveFilename (module.js:326:11) at Function._load (module.js:271:25) at require (module.js:355:19) at Object.(/var/vcap.local/dea/apps/app-07zsn86eb8vspvg0-0-bf2638b3e702ededc5473a0c16608d37/app/gulpfile.js:1:74) at Module._compile (module.js:411:26) at Object..js (module.js:417:10) at Module.load (module.js:343:31) at Function._load (module.js:302:12) at Array. (module.js:430:10) at EventEmitter._tickCallback (node.js:126:26)
The console output says it cannot find Gulp, but my project certainly has gulp.js on the root folder. Also the project works perfectly fine when i preview this from a Webstorm editor - so i dont think there is an issue with the code per se..
Any help much appreciated
James
If your project is public, please, share it with Codenvy's factory feature. So everyone will be able to look what is wrong with the project. (You can access factory on left panel of the IDE)

Get error with "line.slice()" on "karma init"

I was started to read "Developing an AngularJS Edge", and I wanted to set up the various frameworks in use.
The book uses nodejs and karma, along with several other frameworks.
I'm on Win7x32.
I just upgraded my nodejs to the latest, v0.10.18 .
I installed the Karma package with "npm install -g karma". This appeared to complete successfully.
I then ran "karma init", which did this:
% karma init
>
readline.js:507
this.line = this.line.slice(this.cursor);
^
TypeError: Cannot call method 'slice' of undefined
at Interface._deleteLineLeft (readline.js:507:25)
at suggestNextOption (C:\Users\David\AppData\Roaming\npm\node_modules\karma\lib\init.js:167:9)
at nextQuestion (C:\Users\David\AppData\Roaming\npm\node_modules\karma\lib\init.js:235:12)
at process (C:\Users\David\AppData\Roaming\npm\node_modules\karma\lib\init.js:250:10)
at Object.exports.init (C:\Users\David\AppData\Roaming\npm\node_modules\karma\lib\init.js:352:6)
at Object.<anonymous> (C:\Users\David\AppData\Roaming\npm\node_modules\karma\bin\karma:25:37)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
Note that this error is virtually identical to the stack trace reported by this person a month ago, but that report has received no response.
Probably you're using the Git Bash terminal, MinTTY, which doesn't have full support for TTY.
You have 4 options to fix the problem:
Use CMD terminal with the Windows shell (the default Windows console)
Use CMD terminal with the Bash shell (execute "C:\Program Files\Git\bin\bash.exe" --login -i in cmd terminal)
Use Powershell (an alternative terminal typically installed by default in Windows environments)
Use an alternative terminal (or develop a new one :stuck_out_tongue_winking_eye: )
If you just need execute isolated interactive commands like karma init, I recommend option 1 for it and then come back to Git Bash. However I would give a try to Powershell.
The reason for the error with running npm in Cygwin seems to be a known issue with npm. You can use the work around mentioned here,
https://stackoverflow.com/a/22436199/2390020
Faced the same issue.try this
node node_modules/karma/bin/karma init
I got the same error with MINGW64.
Runs properly on default command prompt.
One other likely relevant point that I failed to mention is that I was running these commands from a Cygwin rxvt window.
I just tried completely uninstalling nodejs and reinstalling it.
When I brought up the rxvt window again and ran "npm install -g karma", it failed with the following:
/c/Program Files/nodejs/npm: line 2: $'\r': command not found
/c/Program Files/nodejs/npm: line 4: $'\r': command not found
/c/Program Files/nodejs/npm: line 5: syntax error near unexpected token `$'in\r''
'c/Program Files/nodejs/npm: line 5: `case `uname` in
That led me to search for that error on the web, and I found this thread, which implies that it simply doesn't support Cygwin (unfortunate, but not a huge problem).
When I then brought up a plain, ugly, unfriendly "cmd" window, both the karma installation and "karma init" completed successfully (or at least it gave me the first question in the "init" process).
In my case, the problem was that I was using the git bash terminal in windows. When I ran the command in a cmd window it worked fine.
Run the command in github shell command window. Worked for me.
If you open up the karma file it's just a node script, so an alternative way of executing it would be:
node karma init
This worked for me in the MINGW64/git bash shell

Categories