4

I'm using Windows 7, Visual Studio 2013. I'm trying to set up Gulp in my Client's project.

I've added those Nugets to the project: Node.js version 0.12.0 Npm.js version 1.3.15.10.

For some reason I don't know, when running npm init inside the nuget package manager when the default project is the client, it is not creating a package.json file, no question are asked regarding the file, and the command never exits.

Is this related somehow to the fact that I only worked through the Visual Studio project? Later on I downloaded Node.js through the installer because I saw no version of node.js existed on my pc.

Do I need to install npm also outside of Visual studio? I don't have access to the network there, should I get an .msi file?

Regarding the Gulp nuget package, I've read in other sites that Gulp should be installed through npm using this command: npm install gulp -g -save dev. I can't run that command because I have no network connection, therefore how can I do that only with the gulp nuget package?

Please help me understand what steps are needed to get node.js, npm, and finally Gulp running

  • Can you share the output on the terminal? You should run `npm config set loglevel info` then run the install command again to view the output. – gnerkus May 30 '16 at 09:22
  • Not sure I set log level correctly because the mesaage is the same, but i posted it –  May 30 '16 at 09:44
  • Maybe this could be more helpful: CategoryInfo: NotSpecified: (npm info it worked if it ends with ok:String) [], RemoteException + FullyQualifiedErrorId : NativeCommandError –  May 30 '16 at 09:54
  • that doesn't answer your question but seriously consider using a VM with Linux, or an old Mac/OS/X machine for your development.. You're not gonna go far with Windows and Visual Studio. I know it might seem a hassle now but trust me your problems are not gonna stop there. – George Katsanos Jun 08 '16 at 14:26
  • Our entire team is based on windows..can't just decide to suddently change that. It's been very comfortable for all of us. Why would it be better to change that? –  Jun 08 '16 at 15:26

2 Answers2

0

The command seems to run infinitely because you haven't provided any responses. The npm init command is interactive and will only continue when you've provided a response for each input request.

From the documentation:

This will ask you a bunch of questions, and then write a package.json for you.

If you want to use the default configuration for the package.json, you can run npm init -y instead.

If you invoke it with -f, --force, -y, or --yes, it will use only defaults and not prompt you for any options.

gnerkus
  • 11,357
  • 6
  • 47
  • 71
  • Running `npm init -f` , `npm init -y` result in the same message.. it's running and nothing happens –  May 30 '16 at 10:34
  • Was the `package.json` file created? – gnerkus May 30 '16 at 10:50
  • No it was not created –  May 30 '16 at 10:56
  • Could it be that I'm not using the newest version of Node.js? Or maybe something I forgot to configure? I'm supposed to install the Node.js and the npm on my client project only? –  May 30 '16 at 13:59
  • That's not the problem. Unfortunately, I don't have enough information. `npm init -y` should create the `package.json` file. The message in the question indicates `npm init` works as it should. – gnerkus May 30 '16 at 14:25
  • I'm desperate, the package.json is not created anywhere.. any other ideas maybe? –  May 31 '16 at 09:20
0

I don't know what the deal is with npm init, but my first suggestion is to try a newer version of npm -- the current version is 3.9.6; I suspect you'll have a better time if you use a more up-to-date version. Generally, npm and node are intended to be installed globally, and not for a single package; I don't know a lot about nuget, but that may also be causing trouble (I think if you install npm locally, you should be able to use it just fine, though, like ./node_modules/.bin/npm init --yes, which is why I list it second). You can get the msi to install the lts release of both here, though I gather you don't have network access. If that doesn't work, you can create a package.json by hand fairly easily, and it'll be just as good as the auto-generated one -- here are some reasonable examples. You might also consider filing an issue with npm.

As to what to do to install gulp if you can't run npm i -g, it is easier than you might expect to work around. There is no difference between the gulp that is installed locally and the gulp that is installed locally, they just use two different scripts when you access them. When you require("gulp"), you get the script listed in main, and when you run gulp at the command line, you get the script listed in bin, and both are included in both a local and global install (you can look at gulp's package.json for more details). So, what that means for a global install is that all you need to do is get gulp's bin file (node_modules/gulp/bin/gulp.js, or node_modules/.bin/gulp, which points to node_modules/gulp/bin/gulp.js) on your PATH somehow (you can't just copy the script to a folder on your path, though, it needs all the other things from its folder in node_modules to work too), or you can call the bin script from your local install directly (I'm a linux user, so I'd run the compile task like this: ./node_modules/.bin/gulp compile -- I don't know how to Windows, so I hope that gets you close enough).

prekolna
  • 1,525
  • 11
  • 16
  • Can I even run any npm commands? Do I need it installed if I have no network connection? At the moment I have node.js installed through the .msi file (with npm along). I have downloaded it in my project as well and a .bin folder with a node.cmd created along. What is it used for? –  Jun 07 '16 at 11:00