0

I have been running into this issue for some time now and I can't really find a solution. I've uninstalled and installed Node.js version 10 and 11 several time but the same issue pops up.

After installing, I run the command "node -v" it returns the version however if I run any other commands it gives me the following error.

Other commands I tired.

node help node console.log("hello")

internal/modules/cjs/loader.js:605
    throw err;
    ^

Error: Cannot find module 'C:\install'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:603:15)
    at Function.Module._load (internal/modules/cjs/loader.js:529:25)
    at Function.Module.runMain (internal/modules/cjs/loader.js:774:12)
    at executeUserCode (internal/bootstrap/node.js:499:15)
    at startMainThreadExecution (internal/bootstrap/node.js:436:3)

Thanks

2
  • 1
    They are not recognized because this is not how to use node. Commented Jan 22, 2019 at 12:59
  • Create a folder mytestFolder using command prompt, navigate into the folder, then type npm init if an interactive process starts asking for package name etc, then it is working fine Commented Jan 22, 2019 at 13:01

3 Answers 3

1

if the previous posters information doesnt help you may need to look into your bash_profile and bash_rc files to see what's loading into your terminal window. I recently had an issue where node wouldnt work at all and what happened was that an old version of node had priority inside my terminal and was catching all my node commands and failing

Sign up to request clarification or add additional context in comments.

Comments

1

The command you are trying to execute does not exists in node 'node help node console.log("hello")'

What you should do instead is:

1) In the terminal type:

node

2) press enter

3) Write:

console.log("test");

The result should be:

enter image description here

If you want to see the list of commands available then you should use:

node --help

Comments

0

If you want to run a js command with node in command line you have to use evaluate script flag

node --eval='console.log("hello")'

or

node -e 'console.log("hello")'

or as mention by @NullDev use pipe

echo "console.log('hi')" | node

1 Comment

Jup. Alternatively you could just pipe them to node: $ echo "console.log('hi')" | node

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.