简体   繁体   中英

npm i for package.json dependencies not install anything. gyp ERR! not ok

I have Ubunutu 20.04 and install Node 16.13 with NPM 8.3 . When I use npm i with these package.json dependencies:

  "dependencies": {
    "axios": "^0.21.1",
    "body-parser": "^1.19.0",
    "cors": "^2.8.5",
    "dotenv": "^8.6.0",
    "express": "^4.17.1",
    "webpack": "^4.44.2",
    "webpack-cli": "^3.3.12"
  },
  "devDependencies": {
    "@babel/core": "^7.11.6",
    "@babel/preset-env": "^7.11.5",
    "@types/jest": "^26.0.20",
    "babel-loader": "^8.1.0",
    "babel-polyfill": "^6.26.0",
    "clean-webpack-plugin": "^3.0.0",
    "css-loader": "^4.3.0",
    "file-loader": "^6.1.1",
    "html-webpack-plugin": "^3.2.0",
    "jest": "^26.6.3",
    "mini-css-extract-plugin": "^0.9.0",
    "node-sass": "^4.14.1",
    "nodemon": "^2.0.7",
    "optimize-css-assets-webpack-plugin": "^5.0.4",
    "prettier": "^2.2.1",
    "sass-loader": "^10.0.3",
    "style-loader": "^2.0.0",
    "supertest": "6.1.3",
    "terser-webpack-plugin": "^1.4.5",
    "webpack-dev-server": "^3.11.0",
    "workbox-webpack-plugin": "^5.1.4"
  }
}

This error appeared:

npm ERR! code 1
npm ERR! path /media/ahmedmosman/All my data/udacity/new project/evaluate-news-article/node_modules/node-sass
npm ERR! command failed
npm ERR! command sh -c node scripts/build.js
npm ERR! Building: /usr/bin/node /media/ahmedmosman/All my data/udacity/new project/evaluate-news-article/node_modules/node-gyp/bin/node-gyp.js rebuild --verbose --libsass_ext= --libsass_cflags= --libsass_ldflags= --libsass_library=
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp verb cli [
npm ERR! gyp verb cli   '/usr/bin/node',
npm ERR! gyp verb cli   '/media/ahmedmosman/All my data/udacity/new project/evaluate-news-article/node_modules/node-gyp/bin/node-gyp.js',
npm ERR! gyp verb cli   'rebuild',
npm ERR! gyp verb cli   '--verbose',
npm ERR! gyp verb cli   '--libsass_ext=',
npm ERR! gyp verb cli   '--libsass_cflags=',
npm ERR! gyp verb cli   '--libsass_ldflags=',
npm ERR! gyp verb cli   '--libsass_library='
npm ERR! gyp verb cli ]
npm ERR! gyp info using node-gyp@3.8.0
npm ERR! gyp info using node@16.13.0 | linux | x64
npm ERR! gyp verb command rebuild []
npm ERR! gyp verb command clean []
npm ERR! gyp verb clean removing "build" directory
npm ERR! gyp verb command configure []
npm ERR! gyp verb check python checking for Python executable "python2" in the PATH
npm ERR! gyp verb `which` failed Error: not found: python2
npm ERR! gyp verb `which` failed     at getNotFoundError (/media/ahmedmosman/All my data/udacity/new project/evaluate-news-article/node_modules/node-gyp/node_modules/which/which.js:13:12)
npm ERR! gyp verb `which` failed     at F (/media/ahmedmosman/All my data/udacity/new project/evaluate-news-article/node_modules/node-gyp/node_modules/which/which.js:68:19)
npm ERR! gyp verb `which` failed     at E (/media/ahmedmosman/All my data/udacity/new project/evaluate-news-article/node_modules/node-gyp/node_modules/which/which.js:80:29)
npm ERR! gyp verb `which` failed     at /media/ahmedmosman/All my data/udacity/new project/evaluate-news-article/node_modules/node-gyp/node_modules/which/which.js:89:16
npm ERR! gyp verb `which` failed     at /media/ahmedmosman/All my data/udacity/new project/evaluate-news-article/node_modules/isexe/index.js:42:5
npm ERR! gyp verb `which` failed     at /media/ahmedmosman/All my data/udacity/new project/evaluate-news-article/node_modules/isexe/mode.js:8:5
npm ERR! gyp verb `which` failed     at FSReqCallback.oncomplete (node:fs:198:21)
npm ERR! gyp verb `which` failed  python2 Error: not found: python2
npm ERR! gyp verb `which` failed     at getNotFoundError (/media/ahmedmosman/All my data/udacity/new project/evaluate-news-article/node_modules/node-gyp/node_modules/which/which.js:13:12)
npm ERR! gyp verb `which` failed     at F (/media/ahmedmosman/All my data/udacity/new project/evaluate-news-article/node_modules/node-gyp/node_modules/which/which.js:68:19)
npm ERR! gyp verb `which` failed     at E (/media/ahmedmosman/All my data/udacity/new project/evaluate-news-article/node_modules/node-gyp/node_modules/which/which.js:80:29)
npm ERR! gyp verb `which` failed     at /media/ahmedmosman/All my data/udacity/new project/evaluate-news-article/node_modules/node-gyp/node_modules/which/which.js:89:16
npm ERR! gyp verb `which` failed     at /media/ahmedmosman/All my data/udacity/new project/evaluate-news-article/node_modules/isexe/index.js:42:5
npm ERR! gyp verb `which` failed     at /media/ahmedmosman/All my data/udacity/new project/evaluate-news-article/node_modules/isexe/mode.js:8:5
npm ERR! gyp verb `which` failed     at FSReqCallback.oncomplete (node:fs:198:21) {
npm ERR! gyp verb `which` failed   code: 'ENOENT'
npm ERR! gyp verb `which` failed }
npm ERR! gyp verb check python checking for Python executable "python" in the PATH
npm ERR! gyp verb `which` failed Error: not found: python
npm ERR! gyp verb `which` failed     at getNotFoundError (/media/ahmedmosman/All my data/udacity/new project/evaluate-news-article/node_modules/node-gyp/node_modules/which/which.js:13:12)
npm ERR! gyp verb `which` failed     at F (/media/ahmedmosman/All my data/udacity/new project/evaluate-news-article/node_modules/node-gyp/node_modules/which/which.js:68:19)
npm ERR! gyp verb `which` failed     at E (/media/ahmedmosman/All my data/udacity/new project/evaluate-news-article/node_modules/node-gyp/node_modules/which/which.js:80:29)
npm ERR! gyp verb `which` failed     at /media/ahmedmosman/All my data/udacity/new project/evaluate-news-article/node_modules/node-gyp/node_modules/which/which.js:89:16
npm ERR! gyp verb `which` failed     at /media/ahmedmosman/All my data/udacity/new project/evaluate-news-article/node_modules/isexe/index.js:42:5
npm ERR! gyp verb `which` failed     at /media/ahmedmosman/All my data/udacity/new project/evaluate-news-article/node_modules/isexe/mode.js:8:5
npm ERR! gyp verb `which` failed     at FSReqCallback.oncomplete (node:fs:198:21)
npm ERR! gyp verb `which` failed  python Error: not found: python
npm ERR! gyp verb `which` failed     at getNotFoundError (/media/ahmedmosman/All my data/udacity/new project/evaluate-news-article/node_modules/node-gyp/node_modules/which/which.js:13:12)
npm ERR! gyp verb `which` failed     at F (/media/ahmedmosman/All my data/udacity/new project/evaluate-news-article/node_modules/node-gyp/node_modules/which/which.js:68:19)
npm ERR! gyp verb `which` failed     at E (/media/ahmedmosman/All my data/udacity/new project/evaluate-news-article/node_modules/node-gyp/node_modules/which/which.js:80:29)
npm ERR! gyp verb `which` failed     at /media/ahmedmosman/All my data/udacity/new project/evaluate-news-article/node_modules/node-gyp/node_modules/which/which.js:89:16
npm ERR! gyp verb `which` failed     at /media/ahmedmosman/All my data/udacity/new project/evaluate-news-article/node_modules/isexe/index.js:42:5
npm ERR! gyp verb `which` failed     at /media/ahmedmosman/All my data/udacity/new project/evaluate-news-article/node_modules/isexe/mode.js:8:5
npm ERR! gyp verb `which` failed     at FSReqCallback.oncomplete (node:fs:198:21) {
npm ERR! gyp verb `which` failed   code: 'ENOENT'
npm ERR! gyp verb `which` failed }
npm ERR! gyp ERR! configure error 
npm ERR! gyp ERR! stack Error: Can't find Python executable "python", you can set the PYTHON env variable.
npm ERR! gyp ERR! stack     at PythonFinder.failNoPython (/media/ahmedmosman/All my data/udacity/new project/evaluate-news-article/node_modules/node-gyp/lib/configure.js:484:19)
npm ERR! gyp ERR! stack     at PythonFinder.<anonymous> (/media/ahmedmosman/All my data/udacity/new project/evaluate-news-article/node_modules/node-gyp/lib/configure.js:406:16)
npm ERR! gyp ERR! stack     at F (/media/ahmedmosman/All my data/udacity/new project/evaluate-news-article/node_modules/node-gyp/node_modules/which/which.js:68:16)
npm ERR! gyp ERR! stack     at E (/media/ahmedmosman/All my data/udacity/new project/evaluate-news-article/node_modules/node-gyp/node_modules/which/which.js:80:29)
npm ERR! gyp ERR! stack     at /media/ahmedmosman/All my data/udacity/new project/evaluate-news-article/node_modules/node-gyp/node_modules/which/which.js:89:16
npm ERR! gyp ERR! stack     at /media/ahmedmosman/All my data/udacity/new project/evaluate-news-article/node_modules/isexe/index.js:42:5
npm ERR! gyp ERR! stack     at /media/ahmedmosman/All my data/udacity/new project/evaluate-news-article/node_modules/isexe/mode.js:8:5
npm ERR! gyp ERR! stack     at FSReqCallback.oncomplete (node:fs:198:21)
npm ERR! gyp ERR! System Linux 5.11.0-38-generic
npm ERR! gyp ERR! command "/usr/bin/node" "/media/ahmedmosman/All my data/udacity/new project/evaluate-news-article/node_modules/node-gyp/bin/node-gyp.js" "rebuild" "--verbose" "--libsass_ext=" "--libsass_cflags=" "--libsass_ldflags=" "--libsass_library="
npm ERR! gyp ERR! cwd /media/ahmedmosman/All my data/udacity/new project/evaluate-news-article/node_modules/node-sass
npm ERR! gyp ERR! node -v v16.13.0
npm ERR! gyp ERR! node-gyp -v v3.8.0
npm ERR! gyp ERR! not ok 
npm ERR! Build failed with error code: 1

While:

node-gyp -v 

v8.3.0

So I can't understand:

  1. Why there is 2 node-gyp?

  2. Why is there no node_modules/ present?

  3. How to make npm i work?

The solution is simple:

Just remove Node v16.13 and re-install v 14.18.1. This will allow the setup with no problem.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM