I'm trying to collab with a guy and he's developed his web app using Node on LINUX and I am using Node on Windows 10. For some reason, when I try to launch his server, his package.json didn't have like half of his dependencies listed and I keep having to go and add in things like async, moment, etc... In addition, I'm stuck between this ridiculous error which says that I must use strict-mode because the code contains a let statement, which is a block-scoped declaration and can only be used in strict-mode. But when I run strict-mode, Node then says I can't launch the server because bcrypt is trying to use an octal literal which cannot be used in strict-mode LOL. So I'm literally stuck between a rock and a hard place, but the author of the code says it runs fine on his linux VM.
I don't know if you know this but node looks for the required modules up the directory tree and. I use virtual box and Ubuntu server w/o gui to run my apps but share the folder with windows so I can access the code with an editor however it won't let me install modules in that folder so I install them one folder up.
So basically, does Ubuntu come with project dependencies my default that I don't have because I'm on Windows? I'm kinda confused on what's happening and how I may be able to get this thing operational. The thing is, I'd prefer to avoid running a Linux VM. I got enough software eating up my space and memory as it is.
Obviously, you can't help me with this particular project's code. But in general, I'm trying to get some advice on how you would handle a situation where this kind of thing is happening: you download a project to work on it, and essentially, you are getting all kinds of dependency and strict-mode errors. Is there any sort of "hard reset" i can do to fix this?
This sounds to me as though your partner forgot to add dependencies to the package.json file. Also your partner might have a different Node.JS major version. You should talk to them and define a version you will also use in production. You should both work with the same version.
btw, you can just use a "local" strict mode, so you won't have problems with external dependencies:
'use strict';
module.exports = function() {
// implementation
};
If the dependencies are not listed in the package.json your partner possibly not used the --save flag.
You are running Windows 10? There is a "Ubuntu user-mode" in Windows 10. It's a shim that runs Ubuntu 14 natively under Windows (reversed Wine). So you can try the program under Linux on Windows without a VM.
My guess is what @jlcfly suggested: your partner has some globally installed modules. So many times have I run into the permissions problem when installing Node apps that I just give up and sudo npm whatever . It makes me feel dirty, but I do it anyhow. :/
Are you both using the same version of Node.js? Support for future specification features works well in Node 6.x, which is the latest version, but as you discovered Node 4. which is the stable version needs use strict and has some limitations.
To my knowledge Ubuntu should not come with any already installed dependencies. The only thing for dependencies I can think of is global Node modules are being used. But it is quite strange that Moment would ever be a global Node module.
I would compare versions of Node being used by running: node -v -I think that is a good place to start.
Is this a case of globally installed npm modules instead of locally installed ones? I'm a total noob with node and npm, so I'm no big help. If you find out the issue, though, please post it.
I'd suggest a few things -
get them to run npm list -g --depth=0 in the project on their working VM and send you the output. Then you can do the same on yours and diff the list - it will settle the question of whether they have globally installed dependencies that you don't have; and you can try installing them.
As per other answers, different node versions cause all kinds of chaos. Maybe use NVM (https://github.com/creationix/nvm) and put an .nvmrc file in the root of the project, sets a common version.
As per other answers, give WSL a shot. If you'll excuse me for promoting my own content, I shared a getting started guide a few days ago that might be useful - hashnode.com/post/getting-started-with-windows-su…
To get into your question about pre-installed packages... nah, Linux doesn't get special node packages. However what can happen is that the compiled code will vary for the same dependencies. I've tried copying a fully-installed and working node project out of WSL and tried to run that up in Windows Command Prompt (cmd) and it didn't work. Deleted node_modules and freshly compiled it in cmd and it worked. Anecdotally I've also had a friend hit problems where people had run up projects on OSX, tar.gz'ed the project and tried to deploy on Linux and it didn't work. I can't say if this is really common or if me and my friend have just been unlucky ;)
The other thing that can happen is that one package or other might simply not work on windows. I used to dev on windows in a nearly-100% mac shop and the amount of things that broke just due to the different file path format was...well, frustrating. You also get packages that assume they are running in bash, which they aren't on Windows (in cmd). So if the script calls out to a bash command or tries to run a .sh script, it'll fail. For node I did find the modified/configured "Node.js command prompt" fares much better than raw "Command Prompt".
Hope that helps!