项目之前在mac启动是没问题,放到windows报错了。 就是下面的图片的报错,说什么python,上面刚开始说的是安装node-sass报错了,然后下面说的一个gyp,还有python包。但是我记得我之前安装node-sass也没遇到这个问题呀。
然后我再网上百度了这个答案(没有成功)
npm install -g node-gyp
npm install --global --production windows-build-tools
接着就是说node版本的问题,于是我尝试升级一个和node版本匹配的,项目是4.多的,我node是16,我就下载一个6点多的,接着就报了另一个错。
Error: Node Sass version 6.0.1 is incompatible with ^4.0.0.
最终我降级node.
解决 Error: Node Sass version 6.0.1 is incompatible with ^4.0.0.
最终我成功的版本
然后我用npm也报错了,我用cnpm装的
// 查看当前镜像源
npm config get registry
// npm设置为淘宝镜像源
npm config set registry https://registry.npm.taobao.org
// 切换回官方的
npm config set registry https://registry.npmjs.org
// 安装cnpm
npm i -g cnpm --registry=https://registry.npm.taobao.org
'PORT' 不是内部或外部命令,也不是可运行的程序
"scripts": {
"start": "PORT=3051 react-scripts start",
"start-win": "set PORT=3051 && react-scripts start",
"build": "react-scripts build && rm -rf ../docs/examples-v4 && mv build ../docs/examples-v4",
"test": "react-scripts test --env=jsdom",
"eject": "react-scripts eject"
}
毫无疑问,我再一次安装了一下node,设置了一下node的环境变量。全局下载node包的路径(建议以后安装node默认安装c盘,由其初学者)
我们可以在npm.js官网看一些包的版本匹配的node的版本
windows多加一个这个就好了"start-win": "set PORT=3051 && react-scripts start",