簡體   English   中英

node.js命令在終端中有效,但在npm中失敗

[英]node.js command works in terminal but fails in npm

我有一個很奇怪的問題。 我剛剛更新了項目中的所有dev依賴項,但它破壞了dev:server腳本。 現在,當使用npm或yarn運行它時,我得到以下信息:

npm run dev:server

> my-proj@0.0.0 dev:server C:\Users\George\Source\Repos\my-proj
> cross-env NODE_ENV=development concurrently "tsc -w --project ./server" "nodemon server"

[2] 'server' is not recognized as an internal or external command,
[2] operable program or batch file.
[2] server exited with code 1
[0] Version 2.2.2
[0] Syntax:   tsc [options] [file ...]
[0]
[0]
[0] Examples: tsc hello.ts
[0]           tsc --outFile file.js file.ts
[0]           tsc @args.txt
[0]
[0] Options:
[0]  --allowJs                                          Allow javascript files to be compiled.
[0]  --allowSyntheticDefaultImports      
...              

tsc似乎在抱怨,因為它不了解它應該使用具有自己的tscofig文件的服務器目錄。

但是當進行調查時,我發現在完全相同的終端中cross-env NODE_ENV=development concurrently "tsc -w --project ./server" "nodemon server"運行cross-env NODE_ENV=development concurrently "tsc -w --project ./server" "nodemon server"正常工作嗎? 這表明這是一個npm或yarn漏洞,但是其中的所有漏洞都已更新,並且似乎都不可能突然開發出相同的漏洞!

有任何想法嗎?

注意:我正在使用Windows

cross-env最近更新到了4.0.0版本。

npm info cross-env | grep -B4 "4.0.0':"
 '3.2.2': '2017-03-04T16:13:55.420Z',
 '3.2.3': '2017-03-04T16:44:27.226Z',
 '3.2.4': '2017-03-14T16:24:01.735Z',
 '4.0.0-beta.0': '2017-03-27T01:51:04.557Z',
 '4.0.0': '2017-03-31T02:07:49.386Z' },

您提到了升級開發依賴項后發生的問題。 cross-env是dev依賴項嗎? 這是您更新的依賴項之一嗎? 如果您將其降級,您的腳本會重新開始工作嗎?

我嘗試查找可能會導致您看到錯誤的最近更改,但不能肯定地說。 也許這個https://github.com/kentcdodds/cross-env/commit/ea8002130477f044e66508179394eea485583b2a

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM