【问题标题】:`npm install node-sass` fails with `ENOENT: no such file or directory, mkdir '/node_modules/node-sass/vendor/linux_musl-x64-57'``npm install node-sass` 失败并显示 `ENOENT: no such file or directory, mkdir '/node_modules/node-sass/vendor/linux_musl-x64-57'`
【发布时间】:2021-08-12 15:01:40
【问题描述】:

我正在尝试在节点 8 上安装 node-sass,但它失败了:

$ docker run --rm -i -t --entrypoint ash node:8.10.0-alpine -c 'npm install node-sass'
npm WARN notice [SECURITY] lodash has the following vulnerability: 1 high. Go here for more details: https://www.npmjs.com/advisories?search=lodash&version=4.17.21 - Run `npm i npm@latest -g` to upgrade your npm version, and then `npm audit` to get more info.
npm WARN deprecated request@2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142
npm WARN deprecated har-validator@5.1.5: this library is no longer supported
npm WARN deprecated uuid@3.4.0: Please upgrade  to version 7 or higher.  Older versions may use Math.random() in certain circumstances, which is known to be problematic.  See https://v8.dev/blog/math-random for details.

> node-sass@6.0.1 install /node_modules/node-sass
> node scripts/install.js

Unable to save binary /node_modules/node-sass/vendor/linux_musl-x64-57 : { Error: ENOENT: no such file or directory, mkdir '/node_modules/node-sass/vendor/linux_musl-x64-57'
    at Object.fs.mkdirSync (fs.js:885:18)
    at checkAndDownloadBinary (/node_modules/node-sass/scripts/install.js:113:8)
    at Object.<anonymous> (/node_modules/node-sass/scripts/install.js:156:1)
    at Module._compile (module.js:652:30)
    at Object.Module._extensions..js (module.js:663:10)
    at Module.load (module.js:565:32)
    at tryModuleLoad (module.js:505:12)
    at Function.Module._load (module.js:497:3)
    at Function.Module.runMain (module.js:693:10)
    at startup (bootstrap_node.js:188:16)
  errno: -2,
  code: 'ENOENT',
  syscall: 'mkdir',
  path: '/node_modules/node-sass/vendor/linux_musl-x64-57' }

> node-sass@6.0.1 postinstall /node_modules/node-sass
> node scripts/build.js

Building: /usr/local/bin/node /node_modules/node-gyp/bin/node-gyp.js rebuild --verbose --libsass_ext= --libsass_cflags= --libsass_ldflags= --libsass_library=
gyp info it worked if it ends with ok
gyp verb cli [ '/usr/local/bin/node',
gyp verb cli   '/node_modules/node-gyp/bin/node-gyp.js',
gyp verb cli   'rebuild',
gyp verb cli   '--verbose',
gyp verb cli   '--libsass_ext=',
gyp verb cli   '--libsass_cflags=',
gyp verb cli   '--libsass_ldflags=',
gyp verb cli   '--libsass_library=' ]
gyp info using node-gyp@7.1.2
gyp info using node@8.10.0 | linux | x64
gyp verb command rebuild []
gyp verb command clean []
gyp verb clean removing "build" directory
gyp verb command configure []
gyp verb find Python Python is not set from command line or npm configuration
gyp verb find Python Python is not set from environment variable PYTHON
gyp verb find Python checking if "python3" can be used
gyp verb find Python - executing "python3" to get executable path
gyp verb find Python - "python3" is not in PATH or produced an error
gyp verb find Python checking if "python" can be used
gyp verb find Python - executing "python" to get executable path
gyp verb find Python - "python" is not in PATH or produced an error
gyp verb find Python checking if "python2" can be used
gyp verb find Python - executing "python2" to get executable path
gyp verb find Python - "python2" is not in PATH or produced an error
gyp ERR! find Python
gyp ERR! find Python Python is not set from command line or npm configuration
gyp ERR! find Python Python is not set from environment variable PYTHON
gyp ERR! find Python checking if "python3" can be used
gyp ERR! find Python - "python3" is not in PATH or produced an error
gyp ERR! find Python checking if "python" can be used
gyp ERR! find Python - "python" is not in PATH or produced an error
gyp ERR! find Python checking if "python2" can be used
gyp ERR! find Python - "python2" is not in PATH or produced an error
gyp ERR! find Python
gyp ERR! find Python **********************************************************
gyp ERR! find Python You need to install the latest version of Python.
gyp ERR! find Python Node-gyp should be able to find and use Python. If not,
gyp ERR! find Python you can try one of the following options:
gyp ERR! find Python - Use the switch --python="/path/to/pythonexecutable"
gyp ERR! find Python   (accepted by both node-gyp and npm)
gyp ERR! find Python - Set the environment variable PYTHON
gyp ERR! find Python - Set the npm configuration variable python:
gyp ERR! find Python   npm config set python "/path/to/pythonexecutable"
gyp ERR! find Python For more information consult the documentation at:
gyp ERR! find Python https://github.com/nodejs/node-gyp#installation
gyp ERR! find Python **********************************************************
gyp ERR! find Python
gyp ERR! configure error
gyp ERR! stack Error: Could not find any Python installation to use
gyp ERR! stack     at PythonFinder.fail (/node_modules/node-gyp/lib/find-python.js:302:47)
gyp ERR! stack     at PythonFinder.runChecks (/node_modules/node-gyp/lib/find-python.js:136:21)
gyp ERR! stack     at PythonFinder.<anonymous> (/node_modules/node-gyp/lib/find-python.js:179:16)
gyp ERR! stack     at PythonFinder.execFileCallback (/node_modules/node-gyp/lib/find-python.js:266:16)
gyp ERR! stack     at exithandler (child_process.js:282:5)
gyp ERR! stack     at ChildProcess.errorhandler (child_process.js:294:5)
gyp ERR! stack     at emitOne (events.js:116:13)
gyp ERR! stack     at ChildProcess.emit (events.js:211:7)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:196:12)
gyp ERR! stack     at onErrorNT (internal/child_process.js:372:16)
gyp ERR! System Linux 5.4.72-microsoft-standard-WSL2
gyp ERR! command "/usr/local/bin/node" "/node_modules/node-gyp/bin/node-gyp.js" "rebuild" "--verbose" "--libsass_ext=" "--libsass_cflags=" "--libsass_ldflags=" "--libsass_library="
gyp ERR! cwd /node_modules/node-sass
gyp ERR! node -v v8.10.0
gyp ERR! node-gyp -v v7.1.2
gyp ERR! not ok
Build failed with error code: 1
npm WARN enoent ENOENT: no such file or directory, open '/package.json'
npm WARN !invalid#1 No description
npm WARN !invalid#1 No repository field.
npm WARN !invalid#1 No README data
npm WARN !invalid#1 No license field.

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! node-sass@6.0.1 postinstall: `node scripts/build.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the node-sass@6.0.1 postinstall script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2021-08-12T14_48_49_350Z-debug.log

【问题讨论】:

    标签: node.js npm node-sass


    【解决方案1】:

    npm 正在尝试安装最新的node-sass 版本,6.0.1。根据node-sass official documentation,原来这个版本与node 8不兼容:

    安装最新的兼容版本 (4.14.1) 解决了我的问题:

    $ docker run --rm -i -t --entrypoint ash node:8.10.0-alpine -c 'npm install node-sass@4.14.1'
    npm WARN notice [SECURITY] lodash has the following vulnerability: 1 high. Go here for more details: https://www.npmjs.com/advisories?search=lodash&version=4.17.21 - Run `npm i npm@latest -g` to upgrade your npm version, and then `npm audit` to get more info.
    npm WARN deprecated request@2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142
    npm WARN notice [SECURITY] trim-newlines has the following vulnerability: 1 high. Go here for more details: https://www.npmjs.com/advisories?search=trim-newlines&version=1.0.0 - Run `npm i npm@latest -g` to upgrade your npm version, and then `npm audit` to get more info.
    npm WARN deprecated tar@2.2.2: This version of tar is no longer supported, and will not receive security updates. Please upgrade asap.
    npm WARN deprecated har-validator@5.1.5: this library is no longer supported
    npm WARN deprecated uuid@3.4.0: Please upgrade  to version 7 or higher.  Older versions may use Math.random() in certain circumstances, which is known to be problematic.  See https://v8.dev/blog/math-random for details.
    
    > node-sass@4.14.1 install /node_modules/node-sass
    > node scripts/install.js
    
    Downloading binary from https://github.com/sass/node-sass/releases/download/v4.14.1/linux_musl-x64-57_binding.node
    Download complete  ] - :
    Binary saved to /node_modules/node-sass/vendor/linux_musl-x64-57/binding.node
    Caching binary to /root/.npm/node-sass/4.14.1/linux_musl-x64-57_binding.node
    
    > node-sass@4.14.1 postinstall /node_modules/node-sass
    > node scripts/build.js
    
    Binary found at /node_modules/node-sass/vendor/linux_musl-x64-57/binding.node
    Testing binary
    Binary is fine
    npm WARN saveError ENOENT: no such file or directory, open '/package.json'
    npm notice created a lockfile as package-lock.json. You should commit this file.
    npm WARN enoent ENOENT: no such file or directory, open '/package.json'
    npm WARN !invalid#1 No description
    npm WARN !invalid#1 No repository field.
    npm WARN !invalid#1 No README data
    npm WARN !invalid#1 No license field.
    
    + node-sass@4.14.1
    added 193 packages in 16.761s
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2018-05-01
      • 1970-01-01
      • 2020-09-11
      • 2014-01-20
      • 1970-01-01
      • 1970-01-01
      • 2022-11-01
      相关资源
      最近更新 更多