I am starting to do a new application for the first time and i installed git and node.js and set the path.. With the link from bitbucket i cloned the project then i gave npm install.. Upto this everything was fine but when i gave npm run dev, it was throwing this error:
I think the issue was related to path and i don't know what to change in it. My path looks as below:
The other questions in the forums doesn't solve my issue.
Try to remove the first ';' in your PATH system environment variable. Check that your PATH does not end with ';'
Check also that you don't have multiple value for ComSpec. (and no semicolon)
Related
I'm dealing with a strange issue. When yarn install is ran during my automated CI build, I get the following error:
error C:\GitLab-Runner\builds\6sT6aNYk\0\[redacted]\node_modules\fibers: Command failed.
Exit code: 1
Command: node build.js || nodejs build.js
Arguments:
Directory: C:\GitLab-Runner\builds\6sT6aNYk\0\[redacted]\node_modules\fibers
Output:
'node' is not recognized as an internal or external command,
operable program or batch file.
'nodejs' is not recognized as an internal or external command,
operable program or batch file.
My environment variables are correct. I've manually browsed to the directory, and executed the same command using powershell. Then the command does not fail, and node is found in its installation directory. Powershell is the runner configured for this system/project.
During the CI build I can See node.exe spawning under gitlabrunner.exe. So the path for the process is correct. It's just yarn install that fails to find node.exe.
I'm not a javascript developer, and I do not know how to dive deeper into what is happening. How can I see what causes this problem? Has anyone experienced something like this before?
Other things I've looked at:
path length disabled
Building from other directories in the system (manually, it all works)
Removing node & npm and re-installing
Edit:
The issue also occurs if I use npm install instead of yarn install.
I found the problem. Another item in my build chain was adding items to the path in a loop. previously this was not a problem, but maybe an update added more items.
The solution was to clear the environment and add the original path back.
My computer keeps forgetting that I have node installed despite the fact that all of the files are still there. So far, I have tried installing through the node installer on the nodejs website, using brew, using nvm, and also several of the suggestions in this gist. No matter what I try, within a couple of hours or a couple of days, I am working away and then I am suddenly throwing node errors, and when I check node -v or npm -v, I get the error command not found: node or command not found: npm. The only thing that I can figure out to get node working again is to uninstall whatever I most recently tried and then to reinstall.
It seems like I might be having some sort of env or path issue, but I don't know where to begin to start troubleshooting anything like that.
EDIT
Based on the suggestion below, I added these to my .bash_profile and it seems to have fixed my issue. Not sure why the install wasn't adding them here or in .bashrc, but adding it manually fixed the issue:
export PATH="$HOME/.npm-packages/bin:$PATH"
export PATH="$HOME/.node_modules/bin:$PATH"
maybe you forgot to add node & npm binaries to your path that's why when you open a new instance of your terminal it says that it doesn't know node and npm
Simply add the line that register the binaries into your path within your .profile file that might be located in your home directory
I was trying to change my npm and npm-cache folders to d:\\npm-global and d:\\npm-cache
I managed to do a npm config set cache d:\npm-cache
When I tried to do a npm config set prefix d:\npm-global I accidentally put a ' in the folder string as I was hitting enter. I deleted the errant folder after trying a npm i -g gulp and to my horror, npm stopped working altogether, it just sits there with my command prompt rocking up to 50% CPU usage.
Help please! I've tried searching the registry and other places, even uninstalled and re-installed the nodejs msi package on Windows. This reset the D:\Program Files\nodejs\node_modules\npm\npmrc file.
Still no luck. I can't get npm to work again. :(
edit A little digging in and I realized there is a second node server running via Adobe Creative Cloud. I doubt this is the problem though as when I run npm from the cmd.exe prompt, the correct (d:\program files\nodejs) version of the npm server is executed for that process.
edit so only sometimes when I hit Control-C, I'll get this error:
seems like it's trying to find a file that doesn't exist. However, I cleared out the AppData\Roaming\npm folder and the reinstalls reset the default d:\program files\nodejs\....npm\npmrc file. I also made sure that the environment variable NODE_PATH is not set. It wasn't set when it was working. I set it when I was trying to make my changes.
You should be able to modify your config settings manually by modifying ~/.npmrc
#jakemingolla was right so I marked that answer as accepted (thanks Jake), but I also asked this in the NPM forum and did a little test after I got it working. I thought this might help someone: https://npm.community/t/i-killed-my-npm-on-windows-trying-to-move-some-folders-reinstalling-nodejs-isnt-resetting-the-problem/5743/8?u=chi11ax
Receiving this warning on running a node.js app despite all testing suggesting everything fine.
I've included the below code in my app to fault find:
console.log('NODE_ENV: ' + config.util.getEnv('NODE_ENV'));
console.log('NODE_CONFIG_DIR: ' + config.util.getEnv('NODE_CONFIG_DIR'));
And the output in terminal is:
NODE_ENV: test
NODE_CONFIG_DIR: C:\Users\[username]\OneDrive - [Company Name]\Documents\projects\[project name]\server\config
Terminal Output
Inside that folder (verified by copying and pasting the URI into explorer) are two files:
default.json
test.json
Config folder contents
That seems to be correct to me, I've checked the guidance and can't see anything out, checked google hits and the answers don't appear to relate. Any help would be greatly appreciated.
Though the mentioned package in the accepted answer resolves the issue, it is good not to get more dependencies in your project's package.json when the same can be sorted with a simple tweak as below: -
In your package.json file by omitting the space before &&. This will detect the environment(s) correctly without extra space after the name.
Quick answer:
Use something like cross-env on windows environments: npm cross-env
From what I can find, this appears to fall into the 'Windows issues with NODE_ENV' category. Setting the NODE_ENV separately, prior to starting the app results in the environment working correctly; any manipulation of NODE_ENV inside a package.json script on its own results in failure.
This answer on another question led me to the package cross-env, and when implemented as identified in the answer resolves the issue.
If anyone else has the same error be sure to run the jest command from your project's root directory if you directly use jest cli instead of an npm script
I've updated my project to use node 6.11.3. When I now try to start a npm-script by using the Run-configurations provided from IntelliJ, I always receive the following error:
Error: Failed to replace env in config: ${NODE_EXE}
Important: This error appears only if I start npm from within my project. If I use the windows cmd, the error doesn't appear.
What could possibly have changed between node 6.11.2 and 6.11.3? Because with the prior version, everything worked fine.
A workaround for me is to add the NODE_EXE variable to my run configuration, but In my opinion, that shouldn't be needed, because it worked in 6.11.2 too.
Looks as if you have ${NODE_EXE} variable set in one of your npmrc files (see https://docs.npmjs.com/files/npmrc#files), and it can't be properly expanded for some reason when you run your script in the IDE.
is the issue specific to certain project?
how many npm versions do you have installed? Please check that npm chosen in Node.js Interpreters dialog is the same as you use in cmd shell?
please create an env.js file with console.log(process.env) and try running it via npm ("env" : "node env.js") in both cmd console and WebStorm - what is the result?