J S*_*ith 50 javascript git maven node.js
我有一个maven项目,其中JavaScript项目被克隆为git子模块.所以目录结构看起来像
mavenapp/src/main/javascript/[npm project files]
在我的package.json中,测试看起来像这样: "test": "react-scripts test --env=jsdom",
但当我尝试运行npm测试时说
'react-scripts'不被识别为内部或外部命令,
有趣的是,当我独立克隆javascript项目时,我没有得到这个错误.我试过重新跑步npm install.
npm version : 5.5.1
node version : 9.3.0
Yog*_*rad 50
安装时节点模块目录中缺少react-scripts文件时出错.
检查您的react-script依赖关系是否可用于package.json
如果没有,则通过以下方式手动添加
npm install react-scripts --save
Ras*_*kul 22
2024 答案:只需删除node_modules文件夹并运行
npm install
Run Code Online (Sandbox Code Playgroud)
或者:
yarn
Run Code Online (Sandbox Code Playgroud)
(取决于您使用的npm是 或yarn)
它对我有用!
浪费了我很多时间直到我发现这一点,我很头疼......
Jon*_*mar 21
你有没有尝试过:
rm -rf node_modules && npm install
node_modules首先擦除,往往会解决很多奇怪的,类似于Node的问题.
Had*_*Mir 18
如果react-scripts存在于package.json
如果您"react-scripts": "2.1.3"在pakage.json文件中看到类似的内容 , 则键入以下命令
npm install
如果react-scripts不存在package.json
如果"react-scripts"您的package.json文件中没有类似内容,则可能您尚未安装它。为此,请键入以下命令,您将全部完成
npm install react-scripts --save
小智 16
在我的情况下,我的节点包发生了一些问题。所以我跑了npm audit fix,它解决了所有问题
cri*_*ari 16
运行这些命令对我有用:
npm cache clean --force
npm rebuild
npm install
Run Code Online (Sandbox Code Playgroud)
S. *_*RAN 10
对于便携式应用程序更改
包.json
如下
"scripts": {
"start": "node node_modules/react-scripts/bin/react-scripts start",
"build": "node node_modules/react-scripts/bin/react-scripts build",
"test": "node node_modules/react-scripts/bin/react-scripts test",
"eject": "node node_modules/react-scripts/bin/react-scripts eject"
}
Run Code Online (Sandbox Code Playgroud)
当您运行时, react-scripts应被列为依赖项npx create-react-app your-app,但由于某种原因,它会出现此错误。我将列出我遵循的一些步骤,这些步骤可能会帮助您修复此错误:
首先,检查你的 React package.json是否有react-scripts:例如,你应该看到:
"dependencies": {
...
"react-scripts": "4.0.3",
...
},
Run Code Online (Sandbox Code Playgroud)
如果它已经存在,现在尝试使用以下命令重新安装您的依赖项npm i
如果您仍然遇到相同的错误,请尝试使用 删除您的node_modules ,rm -rf node_modules/然后使用 重新安装您的依赖项npm i
但是如果包react-scripts不在你的package.json文件中,你应该通过你的包管理器安装它,例如:
npm i react-scripts
然后尝试使用以下命令启动你的应用程序npm start
小智 6
我卸载了 Node.js 并显示了隐藏文件。
然后,我删除了C:\Users\yourpcname\AppData\Roaming\和npm文件npm-cache夹。
最后,我安装了新版本的 Node.js。
小智 6
在 cmd 中打开项目根文件夹(package.json 所在的位置)。
运行这个脚本。
npm install react-scriptsRun Code Online (Sandbox Code Playgroud)
如有必要,请清除 npm 缓存。
rd /s /q "node_modules"
del package-lock.json
del -f yarn.lock
# to clean npm cache
npm cache clean --force
# to install packages
npm installRun Code Online (Sandbox Code Playgroud)
希望能帮助到你。
npm installnpm run start如果这不起作用,请尝试安装nodejs并运行修复
或清理 npm 缓存 npm cache clean --force
Edit the system environmental variableEnvironment Variables...Path变量名Edit..C:\Program Files\nodejs列表中是否有,如果没有则添加我遇到过同样的问题。我做了这里建议的一切。但没有任何作用。我在我的node_modules中安装了react-scripts,也使用了缓存,但一切都是徒劳的。然后我只是 npx create-react-app 并将所有代码移到这个新文件夹中并且一切正常。
npx create-react-app myapp
为了避免这个问题再次发生,或者每当有人下载你的项目时你都会遇到这个问题。
最好使用以下命令将其添加到开发依赖项中:
npm install react-scripts --save-dev
Run Code Online (Sandbox Code Playgroud)
它会像这样添加。
"devDependencies": {
"react-scripts": "^4.0.3"
}
Run Code Online (Sandbox Code Playgroud)
提交并推送您的代码。
| 归档时间: |
|
| 查看次数: |
48667 次 |
| 最近记录: |