Differences in nodejs paths between linux and windows - linux

I have create-react-app project and I have a scss file in it.
Inside this file, I have a string like image: url("src/assets/icons/icon1.png");
When I run npm run start in windows everything is ok, but whene i run the same in WSL it gives an 'icon1 file not found' error. It join current file path with target file path.
I think there is a difference between working with start of a path in windows and linux, but I can't find any info about that.
What the differences between working with path starts in this systems and is there any way to use this code in linux without adding / in to beginning of the path?

Related

Installing gulp-sass throwing error

This question seems to be repeated of this link but I cannot figure out how to map a drive letter or share network. I am really sorry for repeating but I need help.
I have a command prompt with default directory pointing to my www folder of wamp server.
D:\wamp\www\
I have install other gulp plugin such as gulp-minify. It works fine without any error. But when I try to install gulp-sass it throws error
It happens to me most of the time like, I have been trying to install plugin such as optipng. It shows same error. Seems like it is searching for a "script" folder inside www which is not there. But the script folder is inside the c drive where the nodejs folder exist. Below is the exact path.
C:\Program Files\nodejs\node_modules\npm\scripts
I don't understand why it is searching in my working directory ?
D:\wamp\www\scripts\install.js
The only problem was with the autorun to set the path of command prompt. Few years back I had set the path of my command prompt to D:\wamp\www\ from registry HKEY_CURRENT_USER\Software\Microsoft\Command Processor
You can access the registry by typing "regedit" in run dialog box (window + r)
i just deleted the autorun file and it started working normally.
Credit link

Command prompt not recognizing MongoDB even when added to environment PATH

I am new to the MEAN stack and am trying to implement a tutorial here:https://scotch.io/tutorials/build-a-restful-api-using-node-and-express-4
I am simply trying to install packages I need which are both node.js, express,js, and MongoDB.
My steps after trying to troubleshoot:
I have installed MongoDB 3.2.1 from their site onto my local machine and it is stored at path C:\Program
Files\MongoDB\Server\3.2\bin\
(I can navigate to C:\Program Files\MongoDB\Server\3.2\bin in my
command prompt window and type mongo and have it run)
I went to Control Panel -> System Settings -> Security -> Advanced -> Environment Varaibles -> and under system varialbles:
Earlier I had to add a path for node.js (C:\Program Files\nodejs works
fine for running node at any directory level)
So I tried adding a system variable: MongoDB at "C:\Program
Files\MongoDB\Server\3.2\bin\mongo"
So the ultimate goal is for me to be able to navigate to a folder strucutre on my desktop and run:
"node --version"
"express --version"
"mongo --version"
and have them all be properly installed and available so that I can move on to my application creation.
Any help would be appreciated, thanks.
The command line works by looking in all of the directories specified by the PATH environment variable.
From what I can see, you've included the name of the executable (mongo) in the PATH, when you just need to include the directory.
Just for completeness, on my PC, the PATH variable looks something like this:
C:\Program Files (x86)\Python35-32\Scripts\;C:\Program Files\apache-maven-3.3.9\bin;C:\Program Files\MongoDB\Server\3.2\bin
Basically path variable in a system stores the paths to executable files and programs.
1 System.
2 Advanced system settings.
3 Environment Variables.
4 Double click on 'path' in your User tab.
5 click 'New'.
6 Then add your mongo bin location.
ex:- my one --> C:\Program Files\MongoDB\Server\3.6\bin.
7 Click OK.
Then try in cmd again for the result
I had the same problem when I did the installation on ParrotOS, when I wanted to run the Mongo shell on the terminal with the command mongo it prompted me that the the command wasn't recognize. Same problem with Windows after I edited the variable path.
The command mongod ran for me the shell in both OS without problems. It could be something that was added with new versions of MongoDB.
If someone else knows more about what this happens, ill be more than happy to know.

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?

When running a command in Intellij, how do I make filenames clickable in the output?

I have a grunt task that I've configured in IntelliJ 11 (sadly can't upgrade to 12 yet). The output of the command contains filenames when there is a problem. I've basically followed the configuration example I saw in the Karma setup video at http://www.youtube.com/watch?v=MVw8N3hTfCI (instructions start at 7:39 but the feature is demonstrated at 10:40).
I've created a new Node.js run configuration, put in the correct path to node, changed the path to the file to be grunt and then listed the Application parameters to be what they should. It runs fine.
The output of my grunt task spits out filenames with absolute paths followed by a colon and a line number, just like in that example. I'm curious why my files aren't clickable though.
I'd expect the path in the last line of this to be clickable:
PhantomJS 1.9.1 (Mac OS X) CookiesTests test set, get, and delete cookie FAILED
AssertError: expected "js-test-value" not to be equal to "js-test-value"
at /Users/matt/Projects/task-core/test/cookies.jstd:17
And it should open the file test/cookies.jstd to line 17.
Is there an opportunity to configure IntelliJ so that it recognizes the output as having file names so that it can activate links?

Running node.js code just displays a node identifier

I have the following code in a file called server.js.
var http = require('http');
http.createServer(function (request, response) {
response.writeHead(200, {'Content-Type': 'text/plain'});
response.end('Hello World\n');
}).listen(8124);
console.log('Server running at http://127.0.0.1:8124/');
I use the command prompt and naviage to the folder where the file recides and then the run the command
node server.js
But I don't get the expected output. Instead I get
The node identifier for {My Machine Name} is v2hrfnqaj.
Note: I already have node installed in my machine and it was working fine.
Was getting this when I was trying to run cordova commands. Steps to resolve:
Windows
In CMD prompt, type "where node". As Michael mentioned, this shows
you the likely culprit, that you have 2 nodejs EXEs installed on
your machine.
Navigate to Start > Computer > Right-click Properties > Advanced system settings
Under the Advanced tab, select Environment Variables
Under System variables, select "Path" variable
Find nodejs EXE, usually "C:\Program Files (x86)\nodejs\"
Cut and paste this to the beginning of the "Path" variable. Ensure
the paths are separated by a ";"
Open a new CMD prompt and try cordova again
This happens when Harvest SCM is installed on your system. It has an executable with the name node.exe at <Program Files (x86)>\CA\SharedComponents\PEC\bin (where <Program Files (x86)> is your x86 program files folder). This path is present in your PATH variable before the path to Node.js's node.exe.
Update: You don't need the elaborate scheme listed in the old answer. You just have to open the Command Prompt and run:
C:\> nodevars
nodevars.bat is a small script that does essentially the same thing described below (but in a safer way). If you have node installed, this script should be in path. (If not make sure to add C:\Program Files\nodejs to your path. But make sure to append it in the end so Harvest SCM does not break).
Everything below is outdated, but I will leave it for the curious reader.
You can do either of following two things you can do to overcome this problem:
Remove <Program Files (x86)>\CA\SharedComponents\PEC\bin from PATH environment variable.
Add/move <Program Files (x86)>\nodejs to the beginning of the PATH environment variable (This is the currently accepted answer from djrpascu).
You can do better!
There are two problems with the above approaches:
You break Harvest SCM's functionality.
If you do not have elevated privileges to change PATH, you are out of options. (Thanks #Glats)
So I created this little batch file, and put it in a directory where I have several other personal scripts (this directory is in my PATH). Here's the gist for the script.
nodecmd.bat
#echo off
set path=%path:C:\Program Files (x86)\CA\SharedComponents\PEC\bin;=%;C:\Program Files (x86)\nodejs;
start %ComSpec%
Then the next time you want to run Node.js, instead of Command Prompt, you open the new script with "Run..." command.
Windows+R
nodecmd
A command prompt will appear. You can use this command prompt to run node without a hassle.
Explanation
This bit deletes the Harvest's executable's path from PATH variable:
%path:C:\Program Files (x86)\CA\SharedComponents\PEC\bin;=%;
And this adds the Node.js's path:
set path=...;C:\Program Files (x86)\nodejs;
The result is a string that contains the original PATH variable minus Harvest's path, plus Node's path. And it is set as PATH variable in the scope of current batch file.
Note: You might have to change the path's in the script to suit software installation folders in your system).
Next line, start %ComSpec% starts a Command Prompt. By this time, the PATH variabe is modified. With modified environment variables, you can run node within this new Command Prompt. The environment variable modification does not affect the rest of the system, making sure that Harvest SCM software runs without breaking.
Don't break your Harvest SCM by removing it from path. Try this one, open your windows command line (cmd) and then pass the following nodejs batch file so that it will set your command line to nodejs environment. Enjoy the node commands there.
C:> "C:\Program Files\nodejs\nodevars.bat"
You can also prioritize in the environments.
Steps:
Computer -> Right click -> Properties -> Advanced system settings -> Environment variables -> PATH(in system variables list) -> Edit -> Prioritize by moving up
This is old, but I ran into this same problem. Exact same message (with my machine name of course). The issue was that there was another node executable on the path, in C:\Program Files (x86)\CA\SharedComponents\PEC\bin. I'm on a windows machine, so running where node showed the two conflicting "node" executables in the path.
To fix the problem, I just removed the CA directory from the PATH environment variable.
I faced the same problem and simply changed the the name of node.exe file from Harvest. This hasn't broken anything from Harvest and I can keep working with it.
Change the Harvest's command name to node_.exe:
ren "C:\Program Files (x86)\CA\SharedComponents\PEC\bin\node.exe" "C:\Program Files (x86)\CA\SharedComponents\PEC\bin\node_.exe"
I think you're running the wrong node command.
Try locating or re-downloading your nodejs installation and add it to your path as the first directory. If you're running linux or unix you can try 'which node' to see what is being run.
Note that in some cases, the node.js executable is called nodejs so you may want to try
nodejs server.js as well
I used the node.js command prompt, instead of the windows default command prompt and it worked for me. Did not know why it did't work in the windows default command prompt.
I was also running with same issue - while defining the path for windows use below parameter
Windows:
set NODE_PATH=C:\nodejs
OR
Set the environment variable for nodejs
NODE_PATH=C:\nodejs
Path= C:\nodejs
(append the path contain this string “c:\nodejs”)

Resources