Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError: shell is not a constructor #16

Closed
forensicsguy20012004 opened this issue Jan 28, 2017 · 8 comments
Closed

TypeError: shell is not a constructor #16

forensicsguy20012004 opened this issue Jan 28, 2017 · 8 comments
Assignees
Labels
Question A relevant question

Comments

@forensicsguy20012004
Copy link

I am running the following: var ps = new shell({executionPolicy: 'Bypass', debugMsg: true, noProfile: true});
and received the following error: [TypeError: shell is not a constructor]

any thoughts

@rannn505
Copy link
Owner

Hey @forensicsguy20012004 ,
I suggest you try to re-install the module.
Besides, did you remember to add this line first?

const shell = require('node-powershell');

Let me know if you managed to solved this, or you need further help.
GL and THx 👍

@rannn505 rannn505 self-assigned this Jan 29, 2017
@rannn505 rannn505 added Question A relevant question question labels Jan 29, 2017
@forensicsguy20012004
Copy link
Author

Hello...thanks for replying back so quickly :)

So I ran the following code....

var shell = require('node-powershell');
var ps = new shell({executionPolicy: 'Bypass', debugMsg: true, noProfile: true});
ps.addCommand('echo "node-powershell rocks"')
.then(function(){
return ps.invoke();
})
.then(function(output){
console.log(output);
ps.dispose();
})
.catch(function(err){
console.log(err);
ps.dispose();
});

I installed via NPM doing: npm install node-powershell --save

I have not been able to get this working...yet...I am hoping I will or I will find something.

I am running v6.9.1 on a Windows 7 box.

@forensicsguy20012004
Copy link
Author

Info: Start process (6:42:23 PM)
Error:
var ps = new shell({executionPolicy: 'Bypass', debugMsg: true, noProfile: true});
^

TypeError: shell is not a constructor
at Object. (c:\NodeProjects\Spartan\node_302d72ae491fb.tmp:3:10)
at Module._compile (module.js:570:32)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
at Module.runMain (module.js:604:10)
at run (bootstrap_node.js:394:7)
at startup (bootstrap_node.js:149:9)
at bootstrap_node.js:509:3

Info: End process (6:42:24 PM)

image

I have run this a couple different ways...so I am not getting an error about the module not being loaded or available. I will try anything.

@rannn505
Copy link
Owner

Hey @forensicsguy20012004 ,
After reading this
The two reasonable things that could happened is that either the module is not loaded correctly from some reason... or that you use shell variable elsewhere in your code ... I would suggest that once again, you will open an empty folder and try to run the example... Anyway I will try to publish a new version at the beginning of next week maybe .. maybe this would solve it.
Have a nice day and keep updating!

@forensicsguy20012004
Copy link
Author

Sorry for responding back so late...I will give that a try and look forward to a new push of your module. Keep up the good work :)

@forensicsguy20012004
Copy link
Author

So, I pulled down your newest version via NPM: "node-powershell": "3.0.1"...still getting the same error. My guess is, it has got to be something that I am doing. I am pretty adept as Node but for some reason this escapes me.

var ps = new shell({executionPolicy: 'Bypass', debugMsg: true, noProfile: true}); ^ TypeError: shell is not a constructor at Object.<anonymous> (C:\nodeprojects\spartan\NodePowershell.js:3:10) at Module._compile (module.js:570:32) at Object.Module._extensions..js (module.js:579:10) at Module.load (module.js:487:32) at tryModuleLoad (module.js:446:12) at Function.Module._load (module.js:438:3) at Module.runMain (module.js:604:10) at run (bootstrap_node.js:394:7) at startup (bootstrap_node.js:149:9) at bootstrap_node.js:509:3

@rannn505
Copy link
Owner

rannn505 commented Mar 2, 2017

Hey @forensicsguy20012004
Please check out the new features entered in the last commit. and try again.
Thx. 👍

@rannn505 rannn505 closed this as completed Mar 2, 2017
@Suppenterrine
Copy link

Hello @rannn505,

I have the same problem as @forensicsguy20012004.
I tried re-installing the module but that didn't fixed the issue for me.

This is the code I was trying to run:

const Shell = require('node-powershell');

const ps = new Shell({
  executionPolicy: 'Bypass',
  noProfile: true
});

ps.addCommand('echo node-powershell');
ps.invoke()
.then(output => {
  console.log(output);
})
.catch(err => {
  console.log(err);
});

I copied this code from StackOverflow and wanted to test it, but I don't know how to workaround this error.
Is it working for you?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Question A relevant question
Projects
None yet
Development

No branches or pull requests

3 participants