[英]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.