Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/node.js/38.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Node.js 术语';CI=假';无法识别为cmdlet、函数、脚本文件或可操作程序的名称_Node.js_Reactjs_Npm_Gitlab Ci_Gitlab Ci Runner - Fatal编程技术网

Node.js 术语';CI=假';无法识别为cmdlet、函数、脚本文件或可操作程序的名称

Node.js 术语';CI=假';无法识别为cmdlet、函数、脚本文件或可操作程序的名称,node.js,reactjs,npm,gitlab-ci,gitlab-ci-runner,Node.js,Reactjs,Npm,Gitlab Ci,Gitlab Ci Runner,我正在尝试使用gitlab的CI/CD,并制作了一个用于构建项目的yml文件。问题是我得到了以下信息: $ npm run build > myreactapp@0.1.0 build C:\GitLab-Runner\builds\QLuLhspz\0\I416547\s4-software-fun-frontend > react-scripts build Creating an optimized production build... Treating warnin

我正在尝试使用gitlab的CI/CD,并制作了一个用于构建项目的yml文件。问题是我得到了以下信息:

$ npm run build
 > myreactapp@0.1.0 build C:\GitLab-Runner\builds\QLuLhspz\0\I416547\s4-software-fun-frontend
 > react-scripts build
 Creating an optimized production build...
 Treating warnings as errors because process.env.CI = true.
 Most CI servers set it automatically.
 Failed to compile.
 ./src/Components/Task/TaskList.js
   Line 120:15:  'currentTasks' is assigned a value but never used                                 no-unused-vars
   Line 175:25:  Headings must have content and the content must be accessible by a screen reader  jsx-a11y/heading-has-content
 ./src/Components/House/House.js
   Line 150:16:  'Address' is assigned a value but never used      no-unused-vars
   Line 150:25:  'HouseNumber' is assigned a value but never used  no-unused-vars
   Line 150:38:  'City' is assigned a value but never used         no-unused-vars
 ./src/Components/House/HouseList.js
   Line 160:25:  Headings must have content and the content must be accessible by a screen reader  jsx-a11y/heading-has-content
 ./src/Components/Person/PersonList.js
   Line 183:25:  Headings must have content and the content must be accessible by a screen reader  jsx-a11y/heading-has-content
 ./src/Components/Footer.js
   Line 2:28:  'Row' is defined but never used  no-unused-vars
 ./src/Components/Person/Person.js
   Line 4:9:     'Link' is defined but never used                  no-unused-vars
   Line 166:16:  'FullName' is assigned a value but never used     no-unused-vars
   Line 166:26:  'PhoneNumber' is assigned a value but never used  no-unused-vars
 npm ERR! code ELIFECYCLE
 npm ERR! errno 1
 npm ERR! myreactapp@0.1.0 build: `react-scripts build`
 npm ERR! Exit status 1
 npm ERR! 
 npm ERR! Failed at the myreactapp@0.1.0 build script.
 npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
 npm ERR! A complete log of this run can be found in:
 npm ERR!     C:\WINDOWS\system32\config\systemprofile\AppData\Roaming\npm-cache\_logs\2020-05-17T11_42_43_915Z-debug.log
Uploading artifacts for failed job
00:00
 ERROR: Job failed: exit status 1
现在它说警告设置为错误,所以我在yml文件中尝试添加
CI=false

stages: ["build", "test", "deploy"]

before_script:
    - npm install
    - CI=false

build:
    stage: build
    script: npm run build

test:
    stage: test
    script: npm run test

deploy:
    stage: deploy
    script: npm run start
但它表示,该命令无法识别。是因为它不是powershell命令还是react.js使用node命令?(无论哪种方式都不起作用)

资料来源:


编辑:发现了问题…与其在yml文件中执行,不如在项目本身中执行

您需要在运行每个相关命令时设置环境变量:
CI=false npm run build
CI=false npm run build

如果在脚本之前将其设置为
,GitLab CI会尝试将其作为独立命令运行(实际上只是设置环境变量)

是因为它不是powershell命令还是react.js使用node命令


Powershell仅适用于Windows,而GitLab CI命令是在Linux上运行的bash命令。React与Node.js无关,尽管CreateReact应用程序使用它。设置的环境变量可以由任何代码读取,无论它是Node.js还是其他任何代码。

您需要在运行每个相关命令时设置环境变量:
CI=false npm run build
CI=false npm run build

如果在脚本之前将其设置为
,GitLab CI会尝试将其作为独立命令运行(实际上只是设置环境变量)

是因为它不是powershell命令还是react.js使用node命令


Powershell仅适用于Windows,而GitLab CI命令是在Linux上运行的bash命令。React与Node.js无关,尽管CreateReact应用程序使用它。设置的环境变量可以由任何代码读取,无论它是Node.js还是其他任何代码。

对于存在此问题的任何人,因为他们正在使用powershell运行脚本:

$env:CI=$false; npm run build;

$env:CI是在powershell中内联设置环境变量的方式。

对于任何有此问题的人,因为他们正在使用powershell运行脚本:

$env:CI=$false; npm run build;

$env:CI是在powershell中内联设置环境变量的方式。

使用windows禁用CI的另一种方法是向package.json添加
build win
脚本:

  "scripts": {
    "build": "CI=false rescripts build",
    "build-win": "set CI=false&&rescripts build"
  }

然后运行
npm运行buildwin
。请注意,
&&
不能被空格包围。

使用windows禁用CI的另一种方法是向package.json添加
build win
脚本:

  "scripts": {
    "build": "CI=false rescripts build",
    "build-win": "set CI=false&&rescripts build"
  }

然后运行
npm运行buildwin
。请注意,
&&
不能被空格包围。

它起作用了,谢谢!成功了,谢谢!