简体   繁体   English

create-react-app 后无法启动项目:错误:找不到模块“C:\Users\pcname\Documents\react-scripts\bin\react-scripts.js”

[英]Unable to start project after create-react-app: Error: Cannot find module 'C:\Users\pcname\Documents\react-scripts\bin\react-scripts.js'

I created a small react project using npx create-react-app to work on some react tutorials but I am unable to start the react app.我使用 npx create-react-app 创建了一个小型反应项目来处理一些反应教程,但我无法启动反应应用程序。 This i the error that I get when trying to run the project:这是我尝试运行项目时遇到的错误:

> test-app@0.1.0 start C:\Users\pcname\Documents\React R&D\Pluralsight\test-app
> react-scripts start

'D\Pluralsight\test-app\node_modules\.bin\' is not recognized as an internal or external command,
operable program or batch file.
internal/modules/cjs/loader.js:983
  throw err;
  ^

Error: Cannot find module 'C:\Users\pcname\Documents\react-scripts\bin\react-scripts.js'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:980:15)
    at Function.Module._load (internal/modules/cjs/loader.js:862:27)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:74:12)
    at internal/main/run_main_module.js:18:47 {
  code: 'MODULE_NOT_FOUND',
  requireStack: []
}
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! test-app@0.1.0 start: `react-scripts start`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the test-app@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\pcnmame\AppData\Roaming\npm-cache\_logs\2020-04-08T22_43_14_881Z-debug.log

I've uninstalled node, reinstalled it.我已经卸载了节点,重新安装了它。 Install react-scripts globally and not globally.全局而不是全局安装 react-scripts。 I've replaced the start script in the package.json to be:我已将 package.json 中的启动脚本替换为:

"start": "node node_modules/react-scripts/scripts/start.js"

and that works.那行得通。 I've also run react-scripts start inside the app folder and again, that works!!我还在 app 文件夹中运行了 react-scripts start ,并且再次运行! But I can't get it to work when I do npm start inside the app folder但是当我在应用程序文件夹中启动 npm 时,我无法让它工作

Bonus: Any tutorials setting up React in Visual Studio (not vs code) without using ASP NET Core would be appreciated.奖励:任何不使用 ASP NET Core 在 Visual Studio 中设置 React(不是 vs 代码)的教程将不胜感激。 I'm currently unable to set up the debugger with VS.我目前无法使用 VS 设置调试器。

This error can happen after you use create-react-app in case you have some invalid character in your path.使用create-react-app后可能会发生此错误,以防您的路径中有一些无效字符。

Remove & from your path.从你的路径中删除&

Change from this:从此改变:

C:\Users\pcname\Documents\React R&D\Pluralsight\test-app

To this:对此:

C:\Users\pcname\Documents\React RD\Pluralsight\test-app

It should work now!它现在应该可以工作了!

re-running npm i solved my problem.重新运行npm i解决了我的问题。 I had the same problem, turns out "reinstalling" npm packages gets rid of the annoying我有同样的问题,原来“重新安装” npm 包摆脱了烦人

Error: Cannot find module 'C:\Users\pcname\Documents\react-scripts\bin\react-scripts.js'.错误:找不到模块“C:\Users\pcname\Documents\react-scripts\bin\react-scripts.js”。 . . . . { code: 'MODULE_NOT_FOUND', requireStack: [] } {代码:'MODULE_NOT_FOUND',requireStack:[]}

error message.错误信息。

i am facing this error, can anyone please help me to get ride of it please !!!我正面临这个错误,谁能帮我解决这个问题!!!

Your environment has been set up for using Node.js 17.9.0 (x64) and npm.您的环境已设置为使用 Node.js 17.9.0 (x64) 和 npm。

C:\Users\lpy> cd desktop C:\Users\lpy> cd 桌面

C:\Users\lpy\Desktop>npx react-native init cws --version 0.68.2 node:internal/modules/cjs/loader:361 throw err; C:\Users\lpy\Desktop>npx react-native init cws --version 0.68.2 node:internal/modules/cjs/loader:361 throw err; ^ ^

Error: Cannot find module 'C:\Users\lpy\AppData\Local\npm-cache_npx\7930a8670f922cdb\node_modules\absolute-path\index.js'.错误:找不到模块“C:\Users\lpy\AppData\Local\npm-cache_npx\7930a8670f922cdb\node_modules\absolute-path\index.js”。 Please verify that the package.json has a valid "main" entry at tryPackage (node:internal/modules/cjs/loader:353:19) at Function.Module._findPath (node:internal/modules/cjs/loader:566:18) at Function.Module._resolveFilename (node:internal/modules/cjs/loader:919:27) at Function.Module._load (node:internal/modules/cjs/loader:778:27) at Module.require (node:internal/modules/cjs/loader:999:19) at require (node:internal/modules/cjs/helpers:102:18) at Object. Please verify that the package.json has a valid "main" entry at tryPackage (node:internal/modules/cjs/loader:353:19) at Function.Module._findPath (node:internal/modules/cjs/loader:566: 18) 在 Function.Module._load (node:internal/modules/cjs/loader:778:27) 上 Function.Module._resolveFilename (node:internal/modules/cjs/loader:919:27) (node:internal/modules/cjs/loader:778:27) :internal/modules/cjs/loader:999:19) 在 Object 的 require (node:internal/modules/cjs/helpers:102:18) 处。 (C:\Users\lpy\AppData\Local\npm-cache_npx\7930a8670f922cdb\node_modules@react-native-community\cli\node_modules\metro-resolver\src\resolve.js:20:24) at Module._compile (node:internal/modules/cjs/loader:1099:14) at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10) at Module.load (node:internal/modules/cjs/loader:975:32) { code: 'MODULE_NOT_FOUND', path: 'C:\Users\lpy\AppData\Local\npm-cache\_npx\7930a8670f922cdb\node_modules\absolute-path\package.json', requestPath: 'absolute-path' } (C:\Users\lpy\AppData\Local\npm-cache_npx\7930a8670f922cdb\node_modules@react-native-community\cli\node_modules\metro-resolver\src\resolve.js:20:24) 在 Module._compile (node :internal/modules/cjs/loader:1099:14) 在 Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10) 在 Module.load (node:internal/modules/cjs/ loader:975:32) { 代码:'MODULE_NOT_FOUND',路径:'C:\Users\lpy\AppData\Local\npm-cache\_npx\7930a8670f922cdb\node_modules\absolute-path\package.json',requestPath:'absolute -小路' }

Node.js v17.9.0 Node.js v17.9.0

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 create-react-app 返回错误:执行时找不到模块“react-scripts/scripts/init.js” - create-react-app returns an Error: Cannot find module 'react-scripts/scripts/init.js' when executed react-scripts:在ubuntu的create-react-app项目上找不到? - react-scripts: not found on create-react-app project on ubuntu? 错误:找不到模块“/app/react-web/react-scripts” - Error: Cannot find module '/app/react-web/react-scripts' create-react-app + npm start - 'react-scripts' 不被识别为内部或外部命令 - create-react-app + npm start - 'react-scripts' is not recognized as an internal or external command 创建一个带有快速“react-scripts”错误的 React 应用程序 - Create a React app with express, 'react-scripts' error create-react-app react-scripts start - ajv-errors:不支持:选项 jsonPointers。 可以使用已弃用的 jsPropertySyntax 代替 - create-react-app react-scripts start - ajv-errors: NOT SUPPORTED: option jsonPointers. Deprecated jsPropertySyntax can be used instead create-react-app 命令卡在使用 cra-template 安装 react react-dom react-scripts - create-react-app command stuck on installing react react-dom react-scripts with cra-template 使用 Moment JS 创建 React-App:找不到模块“./locale” - Create-React-App with Moment JS: Cannot find module “./locale” npm 启动失败:错误:启动:`react-scripts start` - npm start failing: Error: start: `react-scripts start` Create React App 提供的 react-scripts package 需要依赖 - The react-scripts package provided by Create React App requires a dependency
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM