S
S
Svyatoslav Khusamov2017-04-17 23:29:35
Command line
Svyatoslav Khusamov, 2017-04-17 23:29:35

Why does the command not work in the bat file, but there are no errors in the command line?

Here is the command

set NODE_PATH=C:\Program Files\Element2\modules; && cd C:\Program Files\Element2 && nodemon ./index.js -- --config D:\Element2\config.js

When you run it on the command line, everything starts without errors.
But if you push it into a BAT file and run the file, then an error occurs:
D:\Element2>set NODE_PATH=C:\Program Files\Element2\modules;

D:\Element2>nodemon "C:\Program Files\Element2\index.js" -- --config D:\Element2\config.js
[nodemon] 1.11.0
[nodemon] to restart at any time, enter `rs`
[nodemon] watching: *.*
[nodemon] starting `node "C:\\Program Files\\Element2\\index.js" --config D:\Element2\config.js`
module.js:471
    throw err;
    ^

Error: Cannot find module 'D:\Element2\"C:\Program'
    at Function.Module._resolveFilename (module.js:469:15)
    at Function.Module._load (module.js:417:25)
    at Module.runMain (module.js:604:10)
    at run (bootstrap_node.js:393:7)
    at startup (bootstrap_node.js:150:9)
    at bootstrap_node.js:508:3
[nodemon] app crashed - waiting for file changes before starting...

Answer the question

In order to leave comments, you need to log in

3 answer(s)
A
Alexander, 2017-04-18
@NeiroNx

Well, it's obvious - the separator is a space. For a space to be considered part of a variable, the text must be enclosed in quotation marks .
And I also forgot to say that a CD cannot change the disk - it only works within one disk - on which the interpreter is running.
there's also a smiley face :rukalitso:

A
Anton Kiselyov, 2017-04-18
@zamboga

It looks like the quotes in the full path of the file are missing, either in the batch file or in the script itself.
And yet, is it necessary to run in one line through an ampersand? There may be an ambush in this.

S
Svyatoslav Khusamov, 2017-04-18
@khusamov

set NODE_PATH=%ProgramFiles%\Element2\modules;
cd /D %ProgramFiles%\Element2
nodemon index.js -- --config D:\Element2\config.js

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question