npm install 说找不到文件

Posted

技术标签:

【中文标题】npm install 说找不到文件【英文标题】:npm install says cannot find file 【发布时间】:2019-05-05 21:20:33 【问题描述】:

我正在克隆一个 repo,运行 npm install 时出现以下错误

ENOENT:没有这样的文件或目录,重命名 '/Users/waston/Desktop/hm/STEMuli_MaterialUI/node_modules/.staging/client-6b05b6f7/node_modules/@babel/helper-module-imports' -> '/Users/ waston/Desktop/hm/STEMuli_MaterialUI/node_modules/.staging/@babel/helper-module-imports-b86e8d76'

我想如果我这样做 npm install --save-dev @babel/helper-module-imports 可能会解决它,但即使这样做也会给我同样的错误。

package.json(服务器)

    "dependencies": 
        "azure-storage": "^2.10.2",
        "bcryptjs": "^2.4.3",
        "body-parser": "^1.18.2",
        "cd": "^0.3.3",
        "client": "file:client",
        "concurrently": "^3.5.1",
        "express": "^4.16.3",
        "gravatar": "^1.6.0",
        "install": "^0.12.2",
        "into-stream": "^4.0.0",
        "jsonwebtoken": "^8.2.0",
        "mongoose": "^5.0.12",
        "multer": "^1.4.1",
        "multer-azure-storage": "^0.2.0",
        "node-sass": "^4.10.0",
        "npm": "^6.4.1",
        "passport": "^0.4.0",
        "passport-jwt": "^4.0.0",
        "validator": "^9.4.1"
      ,
 "scripts": 
    "client-install": "npm install --prefix client",
    "start": "node server.js",
    "server": "nodemon server.js",
    "client": "npm start --prefix client",
    "dev": "concurrently \"npm run server\" \"npm run client\"",
    "heroku-postbuild": "NPM_CONFIG_PRODUCTION=false npm install --prefix client && npm run build --prefix client"
  

客户端包.json "

dependencies": 
    "@babel/runtime": "7.0.0-beta.55",
    "@material-ui/core": "1.5.0",
    "@material-ui/icons": "2.0.2",
    "@types/googlemaps": "3.30.11",
    "@types/markerclustererplus": "2.1.33",
    "ajv": "6.5.2",
    "axios": "^0.18.0",
    "blueimp-file-upload": "^9.22.0",
    "chartist": "0.10.1",
    "cloudinary-jquery-file-upload": "^2.5.0",
    "cloudinary-react": "^1.0.6",
    "fullcalendar": "^3.0.0",
    "fullcalendar-reactwrapper": "^1.0.7",
    "fullcalendar-reactwrapper-scheduler": "^1.0.7",
    "history": "4.7.2",
    "install": "^0.12.2",
    "jquery": "^3.3.1",
    "jwt-decode": "^2.2.0",
    "material-design-icons": "^3.0.1",
    "moment": "^2.22.2",
    "moment-timezone": "^0.5.21",
    "node-sass-chokidar": "1.3.3",
    "npm": "^6.4.1",
    "npm-run-all": "4.1.3",
    "perfect-scrollbar": "1.4.0",
    "prop-types": "15.6.2",
    "react": "^16.3.1",
    "react-big-calendar": "^0.19.2",
    "react-bootstrap": "^0.32.1",
    "react-bootstrap-sweetalert": "4.4.1",
    "react-chartist": "0.13.1",
    "react-chat-widget": "^2.1.4-1",
    "react-datetime": "2.15.0",
    "react-dnd": "^5.0.0",
    "react-dnd-html5-backend": "^5.0.1",
    "react-dom": "^16.3.1",
    "react-file-viewer": "^0.5.0",
    "react-google-maps": "9.4.5",
    "react-icons": "^3.0.5",
    "react-jvectormap": "0.0.3",
    "react-material-icons": "^1.0.3",
    "react-moment": "^0.7.0",
    "react-nouislider": "2.0.1",
    "react-parallax": "^2.0.0",
    "react-phone-number-input": "^2.2.14",
    "react-player": "^1.6.6",
    "react-redux": "^5.0.7",
    "react-router-dom": "^4.2.2",
    "react-scripts": "1.1.4",
    "react-select": "^2.1.1",
    "react-slick": "0.23.1",
    "react-stepzilla": "^4.8.0",
    "react-svg-icons": "^0.3.0",
    "react-swipeable-views": "0.12.16",
    "react-table": "6.8.6",
    "react-tagsinput": "3.19.0",
    "redux": "^3.7.2",
    "redux-thunk": "^2.2.0",
    "socket.io-client": "^2.1.1",
    "video-react": "^0.13.0"
  ,
  "devDependencies": 
    "babel-cli": "^6.26.0",
    "babel-plugin-module-resolver": "^3.1.1",
    "babel-plugin-import-rename": "^1.0.1",
    "babel-plugin-transform-object-rest-spread": "^6.26.0",
    "babel-plugin-transform-react-jsx": "^6.24.1",
    "babel-preset-es2015": "^6.24.1"
  ,
  "optionalDependencies": 
    "babel-eslint": "^7.2.3",
    "eslint": "^4.19.1",
    "eslint-config-prettier": "^2.9.0",
    "eslint-plugin-prettier": "^2.6.2",
    "eslint-plugin-react": "^7.10.0",
    "prettier": "^1.13.7"
  ,
  "scripts": 
    "build-css": "node-sass-chokidar --include-path ./src --include-path ./node_modules src/ -o src/",
    "watch-css": "npm run build-css && node-sass-chokidar --include-path ./src --include-path ./node_modules src/ -o src/ --watch --recursive",
    "start-js": "react-scripts start",
    "start": "npm-run-all -p watch-css start-js",
    "build": "npm run build-css && react-scripts build",
    "test": "react-scripts test --env=jsdom",
    "eject": "react-scripts eject",
    "lint:check": "eslint . --ext=js,jsx;  exit 0",
    "lint:fix": "eslint . --ext=js,jsx --fix;  exit 0",
    "install:clean": "rm -rf node_modules/ && rm -rf package-lock.json && npm install && npm start",
    "build-package-css": "node-sass-chokidar src/materialComponents/assets/scss/material-kit-react.scss dist/material-kit-react.css",
    "build-package": "npm run build-package-css && babel src --out-dir dist",
    "deploy": "npm run build"
  ,

【问题讨论】:

你能再试试 rm -rf node_modules && npm install 吗? @HarshShah,刚刚试了一下,结果是一样的。 你可以尝试更改 babel/runtime 版本吗? 你的意思是npm install --save @babel/runtime?如果是这样,我只是尝试过同样的事情。 你也可以做一件事删除 package-lock.json 然后删除 npm_modules 并运行命令 npm cache clean 然后运行 ​​$ npm install 【参考方案1】:

删除你的 package-lock.json 和 node_modules 文件夹,然后运行npm install

【讨论】:

我没有忽略答案,我回家后将不得不尝试这个。谢谢! 删除 package-logk.json 帮助了我,而只是删除 node_modules 没有。

以上是关于npm install 说找不到文件的主要内容,如果未能解决你的问题,请参考以下文章

通过 npm 安装后找不到 yarn 命令

打开虚拟机时说找不到vmx文件,该怎么办

npm install 显示错误,找不到 git

尽管 npm install,Gatsby 还是找不到 fs

工匠说找不到数据库

npm install yarn 未安装/找不到命令