error 'env' is not recognized as an internal or external command?
Asked Answered
H

4

11

I am new to node.js i have installed node.js and checked its working fine using commend npm -v , I tried to test it build open source poject from

github https://github.com/quran/quran.com-frontend

the command to run the project was

  npm run dev

I got this error

    C:\Users\Acer\Desktop\quran.com-frontend-master\quran.com-frontend-master>npm run dev

    > [email protected] dev C:\Users\Acer\Desktop\quran.com-frontend-master\quran.com-frontend-master
    > env NODE_PATH='./src' PORT=8000 UV_THREADPOOL_SIZE=100 node ./webpack/webpack-dev-server.js & env NODE_PATH='./src' PORT=8000 node ./bin/server.js

    'env' is not recognized as an internal or external command,
    operable program or batch file.
    'env' is not recognized as an internal or external command,
    operable program or batch file.

    npm ERR! Windows_NT 10.0.14393
    npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "run" "dev"
    npm ERR! node v6.9.2
    npm ERR! npm  v3.10.9
    npm ERR! code ELIFECYCLE
    npm ERR! [email protected] dev: `env NODE_PATH='./src' PORT=8000 UV_THREADPOOL_SIZE=100 node ./webpack/webpack-dev-server.js & env NODE_PATH='./src' PORT=8000 node ./bin/server.js`
    npm ERR! Exit status 1
    npm ERR!
    npm ERR! Failed at the [email protected] dev script 'env NODE_PATH='./src' PORT=8000 UV_THREADPOOL_SIZE=100 node ./webpack/webpack-dev-server.js & env NODE_PATH='./src' PORT=8000 node ./bin/server.js'.
    npm ERR! Make sure you have the latest version of node.js and npm installed.
    npm ERR! If you do, this is most likely a problem with the quran package,
    npm ERR! not with npm itself.
    npm ERR! Tell the author that this fails on your system:
    npm ERR!     env NODE_PATH='./src' PORT=8000 UV_THREADPOOL_SIZE=100 node ./webpack/webpack-dev-server.js & env NODE_PATH='./src' PORT=8000 node ./bin/server.js
    npm ERR! You can get information on how to open an issue for this project with:
    npm ERR!     npm bugs quran
    npm ERR! Or if that isn't available, you can get their info via:
    npm ERR!     npm owner ls quran
    npm ERR! There is likely additional logging output above.
    npm WARN Local package.json exists, but node_modules missing, did you mean to install?

    npm ERR! Please include the following file with any support request:
    npm ERR!     C:\Users\Acer\Desktop\quran.com-frontend-master\quran.com-frontend-master\npm-debug.log
Haeckel answered 21/12, 2016 at 3:47 Comment(0)
S
6

You can use a linux terminal in windows (like git bash). If you use this one you can configure script shell on npm:

// for git bash
$ npm config set script-shell "C:\Program Files\git\bin\bash.exe" 
// or
$ npm config set script-shell "C:\Program Files\git\bin\sh.exe" 

For any other:

$ npm config set script-shell <Your favorite shell>
Solorzano answered 16/6, 2021 at 19:42 Comment(0)
O
5

On windows, the 'env' command it is NOT recognized by default; there I've found two options:

  1. Use another command instead, for instance:
    set VARIABLE_NAME=custom name
  1. Install cygwin and set it's installation path to the windows environment variables. After installing you can use from command line:
    env VARIABLE_NAME=custom name

Here is the link with details for cygwin installation: https://www.howtogeek.com/howto/41382/how-to-use-linux-commands-in-windows-with-cygwin/

Oxtail answered 17/8, 2020 at 17:44 Comment(0)
S
3

I faced this while installing hardhat. This problem is basically the npm trying to run a bash command you can directly run the following command to change the default shell for the script

$ npm config set script-shell "C:\Program Files\git\bin\bash.exe"
Scenarist answered 16/9, 2021 at 6:8 Comment(0)
A
2

Nodejs and npm are different. npm(node package manager) is used to install dependencies of nodejs. The required dependencies for a server will be listed in package.json file. Looks like there is an issue with env module. Try installing the dotenv module using npm

npm install dotenv --save

Before installing this module, update your npm using the command

npm update
Atman answered 21/12, 2016 at 5:33 Comment(3)
i the error is removed however i can't run the projectHaeckel
@Haeckel hey can you show me steps to run it on my system still not working although no more errorsHaeckel
Hi @dacijilole3030, sorry for the delayed response. Make sure to follow the instructions in Readme file listed in the project. Run the node server with npm run dev command and try accessing the url localhost:8001 to check if the server is running.Atman

© 2022 - 2024 — McMap. All rights reserved.