当我在克隆的react.ts项目上使用“ npm run start”时,出现以下错误,并显示消息“找不到文件index.js”

时间:2019-07-26 18:05:04

标签: reactjs npm npm-scripts npm-start react-tsx

我正在一个网站上工作,该网站是我在家中笔记本电脑上克隆的网站,可以在不在办公室时使用。但是,当我运行“ npm run start”时,出现“ Elifecycle”错误,错误号为“ 1”。它还会发送一条错误消息,说明无法找到文件“ index.js”。与使用我的工作VM时运行启动脚本没有问题的项目相同。

到目前为止,我已经尝试过重新克隆存储库。我已经清理了缓存,删除了节点模块并再次安装了npm,但是收到了相同的错误。我也找不到任何index.js文件,想知道它是否与我项目中的index.tsx文件混淆了。到目前为止,我还无法找到任何在线复制完全相同的问题,而我尝试的修复方法是针对非常相似的问题,但没有解决问题。

这是导致问题的步骤,包括我收到的错误消息。

$ npm run start

> rigman@0.1.0 start C:\Users\wedla
> react-scripts start

Could not find a required file.
  Name: index.js
  Searched in: C:\Users\wedla\src
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! rigman@0.1.0 start: `react-scripts start`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the rigman@0.1.0 start 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:\Users\wedla\AppData\Roaming\npm-cache\_logs\2019-07-26T17_47_30_232Z-debug.log

这是我从错误消息中收到的完整日志。

1 verbose cli [ 'C:\\Program Files\\nodejs\\node.exe',
1 verbose cli   'C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js',
1 verbose cli   'run',
1 verbose cli   'start' ]
2 info using npm@6.9.0
3 info using node@v10.16.0
4 verbose config Skipping project config: C:\Users\wedla/.npmrc. (matches userconfig)
5 verbose run-script [ 'prestart', 'start', 'poststart' ]
6 info lifecycle rigman@0.1.0~prestart: rigman@0.1.0
7 info lifecycle rigman@0.1.0~start: rigman@0.1.0
8 verbose lifecycle rigman@0.1.0~start: unsafe-perm in lifecycle true
9 verbose lifecycle rigman@0.1.0~start: PATH: C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\node-gyp-bin;C:\Users\wedla\node_modules\.bin;C:\Program Files\Git\mingw64\bin;C:\Program Files\Git\usr\bin;C:\Users\wedla\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0;C:\Windows\System32\OpenSSH;C:\Program Files\dotnet;C:\Program Files\Microsoft SQL Server\130\Tools\Binn;C:\Program Files\Microsoft SQL Server\Client SDK\ODBC\170\Tools\Binn;C:\Program Files\Git\cmd;C:\Program Files (x86)\Microsoft SDKs\Azure\Storage Emulator;C:\Program Files\nodejs;C:\Users\wedla\AppData\Local\Microsoft\WindowsApps;C:\Users\wedla\.dotnet\tools;C:\Users\wedla\AppData\Local\Programs\Fiddler;C:\Users\wedla\AppData\Local\Programs\Microsoft VS Code\bin;C:\Users\wedla\AppData\Local\Programs\Microsoft VS Code Insiders\bin;C:\Users\wedla\AppData\Roaming\npm
10 verbose lifecycle rigman@0.1.0~start: CWD: C:\Users\wedla
11 silly lifecycle rigman@0.1.0~start: Args: [ '/d /s /c', 'react-scripts start' ]
12 silly lifecycle rigman@0.1.0~start: Returned: code: 1  signal: null
13 info lifecycle rigman@0.1.0~start: Failed to exec start script
14 verbose stack Error: rigman@0.1.0 start: `react-scripts start`
14 verbose stack Exit status 1
14 verbose stack     at EventEmitter.<anonymous> (C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\index.js:301:16)
14 verbose stack     at EventEmitter.emit (events.js:198:13)
14 verbose stack     at ChildProcess.<anonymous> (C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\lib\spawn.js:55:14)
14 verbose stack     at ChildProcess.emit (events.js:198:13)
14 verbose stack     at maybeClose (internal/child_process.js:982:16)
14 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:259:5)
15 verbose pkgid rigman@0.1.0
16 verbose cwd C:\Users\wedla\EnvironmentTools
17 verbose Windows_NT 10.0.17763
18 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "run" "start"
19 verbose node v10.16.0
20 verbose npm  v6.9.0
21 error code ELIFECYCLE
22 error errno 1
23 error rigman@0.1.0 start: `react-scripts start`
23 error Exit status 1
24 error Failed at the rigman@0.1.0 start script.
24 error This is probably not a problem with npm. There is likely additional logging output above.
25 verbose exit [ 1, true ]

当我在工作VM上使用“ npm run start”时,它可以毫无问题地运行启动脚本,并且可以毫无问题地进行编译。我看不到为什么克隆版本会因为存储库是最新的而缺少文件

1 个答案:

答案 0 :(得分:0)

工作VM上是否有index.js?我希望将index.tsx内置到index.js中-也许package.json中有npm脚本。