我最近把我的项目从我的git存储库拉到一台新的计算机上,当我得到它时,我运行npminit
,然后运行npmi
来重新建立项目。
之后,它运行良好,但我注意到没有node_modules文件夹。我在stack上发现了一个问题,建议我删除package-lock.json
并再次运行npm init
,我确实这样做了。这在我的当前目录中创建了node_modules文件夹,但是现在当我运行npm start
脚本时,它在localhost:3000/libruh/Turbowe
上打开了一个开发服务器,这真的很奇怪。这个路径似乎来自我的github存储库的名称(/libruh/TurboWeb
)。
为什么会出现这种情况?我该怎么修?
这是我的package.json
{
"name": "turboweb",
"version": "0.1.0",
"private": true,
"dependencies": {
"@testing-library/jest-dom": "^4.2.4",
"@testing-library/react": "^9.5.0",
"@testing-library/user-event": "^7.2.1",
"axios": "^0.20.0",
"cors": "^2.8.5",
"datejs": "^1.0.0-rc3",
"discord.js": "^12.3.1",
"mysql": "^2.18.1",
"node-fetch": "^2.6.1",
"popmotion": "^8.7.6",
"react": "^16.13.1",
"react-async": "^10.0.1",
"react-dom": "^16.13.1",
"react-icons": "^3.11.0",
"react-router-dom": "^5.2.0",
"react-scripts": "^4.0.0",
"styled-components": "^5.2.0"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"eslintConfig": {
"extends": "react-app"
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
},
"description": "<img src=\"https://raw.githubusercontent.com/Libruh/turboWeb/2402e73219e13ce8b15654e455f3bcddaaec81cd/src/img/logo/bannerblob.svg\" />",
"main": "index.js",
"repository": {
"type": "git",
"url": "git+https://github.com/Libruh/turboWeb.git"
},
"author": "",
"license": "ISC",
"bugs": {
"url": "https://github.com/Libruh/turboWeb/issues"
},
"homepage": "https://github.com/Libruh/turboWeb#readme"
}
我不确定为什么要在拉出回购后运行npminit
,因为您不想初始化项目。换句话说,npm init负责创建一个新的package.json(项目),而不是像您建议的那样创建node_modules文件夹。
我能够通过不调用npminit
而拉取并运行您的项目,并且像往常一样只对依赖项使用npminstall
。之后,项目似乎在localhost上运行得很好,就像预期的那样。