NPM尝试查找Shell脚本失败(NPM Failing on Trying to Find Shell Script)

编程入门 行业动态 更新时间:2024-10-18 18:16:29
NPM尝试查找Shell脚本失败(NPM Failing on Trying to Find Shell Script)

npm run build上的控制台输出npm run build失败:

'' 不被识别为内部或外部命令,可操作程序或批处理文件。

和相关的npm文件:

"scripts": { "postinstall": "jspm install && npm run build", "start": "http-server", "build": "./bin/build-code", "build-home": "./bin/build-home -dw", "build-common-deps": "./bin/build-common-deps -dw", "build-navbar": "./bin/build-navbar -dw", "build-root": "./bin/build-root -dw", "build-angular1": "./bin/build-angular1 -dw", "build-react": "./bin/build-react -w", "build-preact": "./bin/build-preact -dw", "build-vanilla": "./bin/build-vanillajs", "build-angular2": "./bin/build-angular2 -dw" }

看起来它不了解./bin/build-code脚本位置的路径。 根据我的理解,它从package.json的位置查找文件? 因此,如果应用程序在与package.json相同的目录中有一个bin文件夹,那么这是build-code脚本的正确路径,该脚本位于bin文件夹中。 是什么赋予了? 如果重要的话,使用PowerShell运行npm run build 。

PS我试过基本的命令提示符 - 没有变化。 在Cygwin上运行相同版本的人(我们都只是从回购中撤出)说他们必须“将dos结束更改为unix”,这并没有告诉我太多而且似乎不是问题。

Console output on npm run build failure:

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

And the relevant npm file:

"scripts": { "postinstall": "jspm install && npm run build", "start": "http-server", "build": "./bin/build-code", "build-home": "./bin/build-home -dw", "build-common-deps": "./bin/build-common-deps -dw", "build-navbar": "./bin/build-navbar -dw", "build-root": "./bin/build-root -dw", "build-angular1": "./bin/build-angular1 -dw", "build-react": "./bin/build-react -w", "build-preact": "./bin/build-preact -dw", "build-vanilla": "./bin/build-vanillajs", "build-angular2": "./bin/build-angular2 -dw" }

Looks like it's not understanding the pathing to the ./bin/build-code script location. From what I understand, it looks for files from the package.json's location? So, if the app has a bin folder in the same dir as package.json, then this is the correct pathing to the build-code script, which is within the bin folder. What gives? Using PowerShell to run npm run build if it matters.

P.S. I tried with basic Command Prompt - no changes. Someone running the same build (both of us just pulled from repo) on Cygwin said they had to "Change dos endings to unix", which doesn't tell me much and doesn't seem to be the issue.

最满意答案

在我看来, npm正在调用批处理脚本。 批处理文件在CMD.exe中运行(即使从PowerShell调用),也无法识别/作为路径分隔符。 这就是错误消息的来源。

用\ (或\\如果它们需要转义)替换正斜杠。

Looks to me like npm is invoking batch scripts. Batch files are run in CMD.exe (even when invoked from PowerShell), which doesn't recognize / as a path separator. That's where the error message comes from.

Replace the forward slashes with \ (or \\ if they require escaping).

更多推荐

本文发布于:2023-07-17 13:10:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1144937.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:脚本   Shell   NPM   Script   Find

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!