Node "No such file or directory" with certain packages - node.js

I installed two packages via npm:
alsatian#1.0.0-alpha.7
gulp#3.9.1
As I am using nvm to manage my node versions, the CLI files for the two packages were installed at the following paths:
/home/james/.nvm/versions/node/v6.3.1/lib/alsatian/cli/alsatian-cli.js
/home/james/.nvm/versions/node/v6.3.1/lib/gulp/bin/gulp.js
When I run the command gulp, the command runs correctly. However when I run the command alsatian I get the following output:
: No such file or directory
I replaced both CLI files with the following code:
#!/usr/bin/env node
"use strict";
console.log("If you see this, it worked!");
When I typed the command gulp, I get the message If you see this, it worked!. However, when I type the command alsatian I get the same No such file or directory message as before.
Using the which command I am certain that the files I have modified are the correct files for the packages, and by using the stat command I can see that I have the same permissions for the package files.

This was caused by the CLI file for alsatian containing carriage return characters. Enforcing LF line endings solved the issue.

Related

"Command 'npm' not found" after open terminal, but npm -v show it is installed (installation used nvm)

I installed npm and node using nvm, and it work's fine, but after computer rebot it shows some errors.
Right after rebot open dialog (in Polish language) saying:
error loading the file /home/pawel/.profile
/home/pawel/.bashrc: line 5: npm: command not found
You are using nvm which allows you to have multiple versions of Node.js and to automatically select one of them. This works by placing a script at the end of your .bashrc that allows the correct Node.js to be picked up. So if you try to access npm in the beginning of that same script, it won't work because that path has not been set up.

Error in Terminal - bash: export: `/Users/chrisdutton/.rvm/gems/ruby-2.4.0/bin': not a valid identifier

I have updated my OS to Sierra this morning and had all sorts of issues with npm, node etc. I have managed to be able to run grunt and get websites working locally, however I get errors each time I open a new terminal window.
I get the following
-bash: export: `/Users/chrisdutton/.rvm/gems/ruby-2.4.0/bin': not a valid identifier
-bash: uname: command not found
-bash: ps: command not found
chriss-imac:~ chrisdutton$
It allows me to run grunt, bower etc and works fine, but something is not right.
ruby -v = ruby 2.4.0p0 (2016-12-24 revision 57164) [x86_64-darwin16]
npm -v = 5.6.0
node -v = v9.4.0
Homebrew 1.4.3
Please note that these warnings are just used to help the Homebrew maintainers
with debugging if you file an issue. If everything you use Homebrew for is
working fine: please don't worry or file an issue; just ignore this. Thanks!
Warning: Unbrewed header files were found in /usr/local/include.
If you didn't put them there on purpose they could cause problems when
building Homebrew formulae, and may need to be deleted.
Unexpected header files:
/usr/local/include/node/ares.h
/usr/local/include/node/ares_build.h
/usr/local/include/node/ares_rules.h
/usr/local/include/node/ares_version.h
/usr/local/include/node/nameser.h
/usr/local/include/node/node_internals.h
/usr/local/include/node/pthread-fixes.h
/usr/local/include/ruby-2.2.0/ruby.h
/usr/local/include/ruby-2.2.0/ruby/backward/classext.h
/usr/local/include/ruby-2.2.0/ruby/backward/rubyio.h
/usr/local/include/ruby-2.2.0/ruby/backward/rubysig.h
/usr/local/include/ruby-2.2.0/ruby/backward/st.h
/usr/local/include/ruby-2.2.0/ruby/backward/util.h
/usr/local/include/ruby-2.2.0/ruby/debug.h
/usr/local/include/ruby-2.2.0/ruby/defines.h
/usr/local/include/ruby-2.2.0/ruby/digest.h
/usr/local/include/ruby-2.2.0/ruby/encoding.h
/usr/local/include/ruby-2.2.0/ruby/intern.h
/usr/local/include/ruby-2.2.0/ruby/io.h
/usr/local/include/ruby-2.2.0/ruby/missing.h
/usr/local/include/ruby-2.2.0/ruby/oniguruma.h
/usr/local/include/ruby-2.2.0/ruby/re.h
/usr/local/include/ruby-2.2.0/ruby/regex.h
/usr/local/include/ruby-2.2.0/ruby/ruby.h
/usr/local/include/ruby-2.2.0/ruby/st.h
/usr/local/include/ruby-2.2.0/ruby/subst.h
/usr/local/include/ruby-2.2.0/ruby/thread.h
/usr/local/include/ruby-2.2.0/ruby/thread_native.h
/usr/local/include/ruby-2.2.0/ruby/util.h
/usr/local/include/ruby-2.2.0/ruby/version.h
/usr/local/include/ruby-2.2.0/ruby/vm.h
/usr/local/include/ruby-2.2.0/x86_64-darwin11.0/ruby/config.h
/usr/local/include/ublio.h

My eslint is not working in windows with the *.js path argument

I have a node project that is using eslint and it seems to run fine on mac but gives the following command prompt error in a windows machine 'no such file or directory. stat c:\projects\*.js
It doesn't seem to like the *.js argument. If I remove *.js and just point to the directory it works fine. Alternatively, if I explicitly point to a specific file with the full path, that also works.
Here's the lint npm command I'm using
node_modules/.bin/eslint ./*.js ./**/*.js
What makes the *.js incompatible on the windows machine?

Node and Grunt display node identifier message instead of executing

I have installed node on my machine and have two executables, node.exe and nodejs.exe in my directory. Through the NPM I have installed grunt and jshint for grunt; following this guide:
http://strongloop.com/strongblog/use-grunt-js-and-the-power-of-javascript-to-automating-repetitive-tasks/
When I try and run "grunt" "node" or "grunt jshint" into the windows command prompt or Git Bash then I recieve the following response:
The node identifier for <machine number> is <id number>
I have in my path the location to the \nodejs\node.exe file
I do not have admin or root access to my machine, but can put requests in to add permissions or extra items to the Path. However, I was able to get JSHint to work in Sublime Text by specifying the node path as "nodejs/nodejs.exe"
Would changing my path to nodejs.exe instead fix this; or is there a deeper issue into the setup I have configured that would be causing this problem?
check your system %PATH% variable (echo %PATH%). Most certainly there is another application called node.bat, node.cmd or node.exe that is in your PATH before nodejs and thats why the system finds this first. I'm 99% sure that this is not the output from nodejs
if you have access to your path try to prepend the nodejs path

Grunt on Windows 8: 'grunt' is not recognized

I'm having a problem running Grunt from the command line on my Windows 8 machine.
My research indicates the most common solution is to install grunt-cli, since Grunt is no longer global. I also need to make sure I actually install the Grunt task runner, since that's not installed with grunt-cli.
Other solutions point to the PATH system environment variable, but that appears to be pointed as I'd expect to:
C:\Users[username]\AppData\Roaming\npm
Having done all that, I'm still getting a "'grunt' is not recognized as an internal or external command, operable program or batch file" error message in the CLI. I've tried the following things, uninstalling everything after every attempt:
Installed grunt-cli globally (npm install -g grunt-cli), then grunt at the directory level I want to use it (npm install grunt)
The same as above, but with the order of installation reversed
The same as both of the above, but using the Admin Command Prompt
Am I missing something obvious?
I've not had any issues with grunt on several different windows 8 machines.
If you open the folder: C:\Users\[username]\AppData\Roaming\npm
Do you have a file named grunt.cmd in this folder?
If not I'd maybe try npm install -g grunt-cli again, maybe from an elevated command prompt.
If this exists and you have C:\Users\[username]\AppData\Roaming\npm in your PATH environment variable then typing grunt from a command prompt should work.
Silly question, have you tried closing the command prompt and opening a new one?
Confirm your PATH is correct (and not messed up). Just type PATH from the command prompt. There's really no other explanation that makes sense given the error you're describing and the steps you've taken.
Normally, using the where grunt command would have found grunt.cmd in your path if npm is installed correctly and it has been properly added to the system path.
Close all Command Prompt instances.
Start a new Command Prompt instance.
Type PATH Enter and verify if C:\Users\Username\AppData\Roaming\npm is part of the path.
If not, you need to log off and on again,or close the Command Prompt and restart the explorer process.
In the Command Prompt, type where grunt Enter.
You're good if it reports:
C:\Users\Username\AppData\Roaming\npm\grunt
C:\Users\Username\AppData\Roaming\npm\grunt.cmd
Otherwise, you have to reinstall the grunt-cli package if it reports:
INFO: Could not find files for the given pattern(s).
Apparently, programs that change the PATH environment variable must broadcast a WM_SETTINGCHANGE message. The Windows' System settings window does it correctly when you change the PATH variable, but the NPM installer doesn't. That's why you have to restart explorer (or log off or restart, which has the same effect).
I know this has been answered but I thought I'd offer my step by step solution for windows 8.
First thing I checked was the PATH in my laptops Environment Variables (Right click my computer > properties > advanced system settings > Environment Variables)
It wasn't listed in there so I added a new variable in User variables (so it was specific only to my user account)
In the new user variable prompt I entered the following;
Variable Name: PATH
Variable Value: %USERPROFILE%\AppData\Roaming\npm
Quit command prompt, repoened, navigated to my projects directory and tried running grunt again and... SUCCESS!
I had the same issue.
I tried different things:
Restart computer
Deleted the grunt folder and ran
npm install -g grunt -cli
Didn't work.
Finally tried:
npm install -g grunt-cli
Worked perfectly.
Tried
where grunt
and I saw 2 locations where it was found.
I was facing the same problem on windows 8
I have added ' %APPDATA%\npm ' to the path variable . It has been working fine.
some times NPM install corrupts the basic windows path. i usually have a copy of my own version of PATH mainted separately. every week or on some installs i manually configure and update the %PATH% variable.
Basically Grunt.cmd is not availbe through %PATH% variable.
I have stucked with problem on Windows 8, that after install grunt-cli I've always got "command not found" while I'm tried to check grunt -v or where grunt. So I've added to enviroment PATH this path C:\Program Files (x86)\Git\local and run grunt.cmd from that folder (you need to look in node_modules folder here). And after reloading my terminal everything started to work.
Same happened to me and here was the solution:
Have you got 2 different versions of Node.JS installed?
Maybe Nodist?
This means you likely got NPM installed twice which will install the commands into 2 different folders:
Once into C:\Users\<user>\AppData\Roaming\npm and once into C:\dev\nodist\bin\bin.
C:\dev\nodist\bin\bin wasn't on my path variable so I added it, and I removed the Node.JS version I didn't want to use.
If you have no grunt.cmd file created by npm, make sure that you do not have a .npmrc in your home directory with: bin-links=false in it.
After getting a tonne of "'grunt' is not recognized as an internal or external command," errors, I solved this on Windows 10 by going to Path and adding C:\Users\Username\AppData\Roaming\npm

Resources