I suspect i could have changed where node modules are installed.I have installed express-generator globally.
D:\chirp> npm install express-generator -g
When i try running
D:\chirp> express --ejs
An error popsup in the Command prompt saying
'express' is not recognised as an internal or external
command,operable program or batch file
Here is a screenshot image
Run
npm bin -g
To see where npm installs it's global binaries. Then add that directory to your PATH.
SET PATH=%PATH%;[new directory]
And add it permanently using the way that you should on your system.
simply use
npx express-generator [your projectName]
Related
I want to install react-native cli but I don't where to run this command: npm install -g react-native-cli. Do I need to run this command on my macOS terminal or when I will make a directory for my react native app then there I need to run this command in vscode?
Is there any issue if I run this command in my terminal or If I run this in VScode?
React Native is distributed as two npm packages, react-native-cli and react-native.
The first one is a lightweight package that should be installed globally (npm install -g react-native-cli), while the second one contains the actual React Native framework code and is installed locally into your project when you run react-native init.
Because react-native init calls npm install react-native, simply linking your local GitHub clone into npm is not enough to test local changes.
npm install –g react-native-cli
· This line installs the npm package react-native-cli along with its dependencies(from the npm repository host) inside the globally shared node_modules folder.
· Global install (with -g): puts stuff in /usr/local or wherever node is installed. This will also allow you to access the module from the command-line, as the bin is symlinked into a PATH folder (usually usr/local/bin).
Refer below link
https://rlogicaltech.medium.com/how-to-install-react-native-on-mac-step-by-step-guide-1ac822aedd4f
You can run the command anywhere in the terminal.
It will install the react-native-cli globally as we are specifying the "-g" option in the command.
Use this
npm install -g expo-cli
this how I solved it.
npm install -save react-native#latest
I am learning NODE js and i have a server file that includes NODE_env as port configuration , the code works on a MAC but throws up an error on my windows. How do i solve this?
Have you tried installing it globally or include it in your project's or your library's optional dependencies?
if not, try this:
install globally:
npm install -g win-node-env
Or you may include it in your project's or your library's optional dependencies:
npm install --save-optional win-node-env
refer below link for more information
npmjs win-node-env
If you run into this problem in 2021, install cross-env as a dev dependency by running npm i -D cross-env.
Then, modify your command in the package.json file thus:
cross-env NODE_ENV=development node my_script.js
Are you asking how to set NODE_ENV in windows? You can set it as a user or machine environment variable. You can also set it when you call the script in the command line:
NODE_ENV=development node my_script.js
After setting new windows in my laptop,i am trying to install npm in command prompt.But i am facing an error which picture is given in below.Would anybody help me out?
If you don't specify a package to install (like npm install -g nodemon) npm will try to install all packages from the current package.json file. If there is non, npm will throw this error.
Npm is already installed. That is why the error message is not Command not found.
The specific command you issued npm install -g attempts to use npm to install the package in the current directory globally.
Leaving the point that installing packages globally is a bad idea aside, this is failing because you are running the command in a directory that does not contain a package. It is your home directory, not one containing a package.json file.
If you are trying to install npm(node package manager) do it by downloading it from here: https://www.npmjs.com/get-npm, then you are good to go.
The command you are actually giving is to install a package using npm(check https://docs.npmjs.com/cli/install).
Thats why the error shows could not install from "" as you have not specified any package to install.
I am using yarn v1.6.0 as a dependency manager, I have installed live-server globally by using the following command:
yarn global-add live-server
But when executed it like live server, it is giving the following error:
'live-server' is not recognized as an internal or external command,
operable program or batch file.
It is obvious my path is not configured Can some help which path should I use an environment variable?
I tried to see my version of live-server but got this error,You can use
npm install -g live-server
in your npm command line
All the packages you download from yarn gets stored in bin folder inside yarn directory. So, you have to set the path of the bin folder of your yarn in PATH environment variable as you might have did with the bin directory of the npm.
1). The following path would get you to the bin folder in Windows machine then set this path to the PATH environment variable.
C:\Users\Username\AppData\Local\Yarn\bin
2). For macOS do the following
$ export PATH=$PATH:/home/user/.yarn/bin/
Copy the path of the bin of the yarn.
C:\Users\USER NAME\AppData\Local\Yarn\bin
Go to the Environment variables.
Select, path -> new -> paste the copied path.
Reopen the cmd and type
live-server -v
I have a project which I will have to deploy to client Windows systems where it will not be possible to connect to internet. I currently have a folder in D:\NODE which contains node.exe and npm.cmd and a node_modules folder. To be able to run node from command line I have added D:\NODE to PATH variable.
I can have most of the modules installed locally inside node_modules of my project. However there's one - node-windows - which needs to be installed globally to work.
Following suggestion below I went to node-windows (installed globally) and packaged it up (npm pack), which created a tarball. I have then copied that file with my project and tried to install it on the test machine globally like this: npm install -g node-windows-0.1.5.tgz
I can see that it got installed in the global directory. However when I try to run the command which uses this module it complains that it cannot find it: Error: Cannot find module 'node-windows'
When I list the modules (npm list -g) it is clearly there in the list...
What do you think? And thank you.
You can install packages on a system without internet connection by packing them using built-in functionality in npm. This way, the node modules will be installed properly.
Create a package.json.
In your package.json, list all the modules you need under bundledDependencies (docs on npm).
Run npm install to install your node files before packing.
Create a tarball with npm pack.
Copy the tarball over to the machine without internet connection.
Install the modules with npm install <filename>.
Update
Regarding your comments, it looks like your globally installed node modules isn't found.
Try using the npm link command (docs on npm link):
cd yourAppFolder
npm link node-windows
1 - In system with internet access install module with this command:
npm install [module name]
2 - go to %userprofile%\AppData\Roaming\npm\node_modules[module name]\
(e.g C:\Users\janson\AppData\Roaming\npm\node_modules\grunt-cli)
3 - run npm pack
4 - this should result in a [module name]-x.y.z.tgz file
5 - run npm i -g [module name]-x.y.z.tgz in offline system