美文网首页
windows下npm install报错node-sass无法

windows下npm install报错node-sass无法

作者: DragonersLi | 来源:发表于2021-04-10 04:16 被阅读0次

    windows下执行npm install 报错node-sass无法下载
    原因缺少缺少编译环境python2
    运行npm install -g node-gyp
    然后运行npm install --global --production windows-build-tools
    可以自动安装跨平台的编译器:gym
    使用淘宝镜像安装npm install node-sass --registry=http://registry.npm.taobao.org
    或直接npm install node-sass --save-dev
    npm uninstall node-sass #卸载
    【手动删除node_cache\node-sass下安装失败的版本,例如我的这个目录在D:\Program\Coding\NodeJs\node_cache\node-sass,下面有3.13.1空目录,删除。然后在package.json配置文件手动修改版本:"node-sass": "^5.0.0", 然后重新执行npm install这次成功了,生成了版本5.0.0,目录下有一个文件win32-x64-83_binding.node
    npm install node-sass #重装

    #安装成功
    + node-sass@5.0.0
    removed 1 package and updated 1 package in 74.08s
    
    35 packages are looking for funding
      run `npm fund` for details
    
    
    √ Installed 43 packages
    √ Linked 0 latest versions
    √ Run 0 scripts
    √ All packages installed (used 301ms(network 106ms), speed 0B/s, json 0(0B), tarball 0B)
    
    D:\WorkSpace\wwwroot\gitHub\blog-code\themes\yilia>tree
    ...
    D:\WorkSpace\wwwroot\gitHub\blog-code\themes\yilia>nmp run dev
    ...
    D:\WorkSpace\wwwroot\gitHub\blog-code\themes\yilia>nmp run dist
    ...
    
    #具体报错如下:
     D:\WorkSpace\wwwroot\gitHub\blog-code\themes\yilia>cnpm install
    ...
    Downloading binary from https://cdn.npm.taobao.org/dist/node-sass/v3.13.1/win32-x64-83_binding.node
    Cannot download "https://cdn.npm.taobao.org/dist/node-sass/v3.13.1/win32-x64-83_binding.node":
    
    HTTP error 404 Not Found
    
    Hint: If github.com is not accessible in your location
          try setting a proxy via HTTP_PROXY, e.g.
    
          export HTTP_PROXY=http://example.com:1234
    
    or configure npm proxy via
    
          npm config set proxy http://example.com:8080
    [3/3] scripts.install node-sass@^3.9.3 finished in 774ms
    [3/3] scripts.postinstall node-sass@^3.9.3 run "node scripts/build.js", root: "D:\\WorkSpace\\wwwroot\\gitHub\\blog-code\\themes\\yilia\\node_modules\\_node-sass@3.13.1@node-sass"
    Building: D:\Program\Coding\NodeJs\node.exe D:\WorkSpace\wwwroot\gitHub\blog-code\themes\yilia\node_modules\_node-gyp@3.8.0@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 [
    gyp verb cli   'D:\\Program\\Coding\\NodeJs\\node.exe',
    gyp verb cli   'D:\\WorkSpace\\wwwroot\\gitHub\\blog-code\\themes\\yilia\\node_modules\\_node-gyp@3.8.0@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 verb cli ]
    gyp info using node-gyp@3.8.0
    gyp info using node@14.16.0 | win32 | x64
    gyp verb command rebuild []
    gyp verb command clean []
    gyp verb clean removing "build" directory
    gyp verb command configure []
    gyp verb download using dist-url https://npm.taobao.org/mirrors/node
    gyp verb check python checking for Python executable "python2" in the PATH
    gyp verb `which` failed Error: not found: python2
    gyp verb `which` failed     at getNotFoundError (D:\WorkSpace\wwwroot\gitHub\blog-code\themes\yilia\node_modules\_which@1.3.1@which\which.js:13:12)
    gyp verb `which` failed     at F (D:\WorkSpace\wwwroot\gitHub\blog-code\themes\yilia\node_modules\_which@1.3.1@which\which.js:68:19)
    gyp verb `which` failed     at E (D:\WorkSpace\wwwroot\gitHub\blog-code\themes\yilia\node_modules\_which@1.3.1@which\which.js:80:29)
    gyp verb `which` failed     at D:\WorkSpace\wwwroot\gitHub\blog-code\themes\yilia\node_modules\_which@1.3.1@which\which.js:89:16
    gyp verb `which` failed     at D:\WorkSpace\wwwroot\gitHub\blog-code\themes\yilia\node_modules\_isexe@2.0.0@isexe\index.js:42:5
    gyp verb `which` failed     at D:\WorkSpace\wwwroot\gitHub\blog-code\themes\yilia\node_modules\_isexe@2.0.0@isexe\windows.js:36:5
    gyp verb `which` failed     at FSReqCallback.oncomplete (fs.js:183:21)
    gyp verb `which` failed  python2 Error: not found: python2
    gyp verb `which` failed     at getNotFoundError (D:\WorkSpace\wwwroot\gitHub\blog-code\themes\yilia\node_modules\_which@1.3.1@which\which.js:13:12)
    gyp verb `which` failed     at F (D:\WorkSpace\wwwroot\gitHub\blog-code\themes\yilia\node_modules\_which@1.3.1@which\which.js:68:19)
    gyp verb `which` failed     at E (D:\WorkSpace\wwwroot\gitHub\blog-code\themes\yilia\node_modules\_which@1.3.1@which\which.js:80:29)
    gyp verb `which` failed     at D:\WorkSpace\wwwroot\gitHub\blog-code\themes\yilia\node_modules\_which@1.3.1@which\which.js:89:16
    gyp verb `which` failed     at D:\WorkSpace\wwwroot\gitHub\blog-code\themes\yilia\node_modules\_isexe@2.0.0@isexe\index.js:42:5
    gyp verb `which` failed     at D:\WorkSpace\wwwroot\gitHub\blog-code\themes\yilia\node_modules\_isexe@2.0.0@isexe\windows.js:36:5
    gyp verb `which` failed     at FSReqCallback.oncomplete (fs.js:183:21) {
    gyp verb `which` failed   code: 'ENOENT'
    gyp verb `which` failed }
    gyp verb check python checking for Python executable "python" in the PATH
    gyp verb `which` succeeded python D:\Program\Coding\Python\python.EXE
    gyp ERR! configure error
    gyp ERR! stack Error: Command failed: D:\Program\Coding\Python\python.EXE -c import sys; print "%s.%s.%s" % sys.version_info[:3];
    gyp ERR! stack   File "<string>", line 1
    gyp ERR! stack     import sys; print "%s.%s.%s" % sys.version_info[:3];
    gyp ERR! stack                       ^
    gyp ERR! stack SyntaxError: invalid syntax
    gyp ERR! stack
    gyp ERR! stack     at ChildProcess.exithandler (child_process.js:308:12)
    gyp ERR! stack     at ChildProcess.emit (events.js:315:20)
    gyp ERR! stack     at maybeClose (internal/child_process.js:1048:16)
    gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:288:5)
    gyp ERR! System Windows_NT 10.0.18363
    gyp ERR! command "D:\\Program\\Coding\\NodeJs\\node.exe" "D:\\WorkSpace\\wwwroot\\gitHub\\blog-code\\themes\\yilia\\node_modules\\_node-gyp@3.8.0@node-gyp\\bin\\node-gyp.js" "rebuild"
    "--verbose" "--libsass_ext=" "--libsass_cflags=" "--libsass_ldflags=" "--libsass_library="
    gyp ERR! cwd D:\WorkSpace\wwwroot\gitHub\blog-code\themes\yilia\node_modules\_node-sass@3.13.1@node-sass
    gyp ERR! node -v v14.16.0
    gyp ERR! node-gyp -v v3.8.0
    gyp ERR! not ok
    Build failed with error code: 1
    [npminstall:runscript:error] node-sass@^3.9.3 scripts.postinstall run "node scripts/build.js" error: Error [RunScriptError]: Run "C:\WINDOWS\system32\cmd.exe /d /s /c node scripts/buil
    d.js" error, exit code 1
        at ChildProcess.<anonymous> (D:\Program\Coding\NodeJs\node_modules\cnpm\node_modules\runscript\index.js:96:21)
        at ChildProcess.emit (events.js:315:20)
        at maybeClose (internal/child_process.js:1048:16)
        at Process.ChildProcess._handle.onexit (internal/child_process.js:288:5) {
      stdio: [Object],
      exitcode: 1
    }
    × Install fail! RunScriptError: post install error, please remove node_modules before retry!
    Run "C:\WINDOWS\system32\cmd.exe /d /s /c node scripts/build.js" error, exit code 1
    RunScriptError: Run "C:\WINDOWS\system32\cmd.exe /d /s /c node scripts/build.js" error, exit code 1
        at ChildProcess.<anonymous> (D:\Program\Coding\NodeJs\node_modules\cnpm\node_modules\runscript\index.js:96:21)
        at ChildProcess.emit (events.js:315:20)
        at maybeClose (internal/child_process.js:1048:16)
        at Process.ChildProcess._handle.onexit (internal/child_process.js:288:5)
    npminstall version: 3.28.0
    npminstall args: D:\Program\Coding\NodeJs\node.exe D:\Program\Coding\NodeJs\node_modules\cnpm\node_modules\npminstall\bin\install.js --fix-bug-versions --china --userconfig=C:\Users\Dr
    agonersLi\.cnpmrc --disturl=https://npm.taobao.org/mirrors/node --registry=https://r.npm.taobao.org
    
    D:\WorkSpace\wwwroot\gitHub\blog-code\themes\yilia>npm i node-sass --sass_binary_site=https://npm.taobao.org/mirrors/node-sass/
    npm WARN deprecated fsevents@1.2.13: fsevents 1 will break on node v14+ and could be using insecure binaries. Upgrade to fsevents 2.
    npm WARN rm not removing D:\WorkSpace\wwwroot\gitHub\blog-code\themes\yilia\node_modules\.bin\hexo.ps1 as it wasn't installed by D:\WorkSpace\wwwroot\gitHub\blog-code\themes\yilia\node
    _modules\hexo-cli
    npm WARN rm not removing D:\WorkSpace\wwwroot\gitHub\blog-code\themes\yilia\node_modules\.bin\hexo.cmd as it wasn't installed by D:\WorkSpace\wwwroot\gitHub\blog-code\themes\yilia\node
    _modules\hexo-cli
    npm WARN rm not removing D:\WorkSpace\wwwroot\gitHub\blog-code\themes\yilia\node_modules\.bin\hexo as it wasn't installed by D:\WorkSpace\wwwroot\gitHub\blog-code\themes\yilia\node_mod
    ules\hexo-cli
    npm WARN request-promise-core@1.1.4 requires a peer of request@^2.34 but none is installed. You must install peer dependencies yourself.
    
    npm ERR! code ENOENT
    npm ERR! syscall rename
    npm ERR! path D:\WorkSpace\wwwroot\gitHub\blog-code\themes\yilia\node_modules\_align-text@0.1.4@align-text\node_modules\repeat-string
    npm ERR! dest D:\WorkSpace\wwwroot\gitHub\blog-code\themes\yilia\node_modules\_align-text@0.1.4@align-text\node_modules\repeat-string
    npm ERR! errno -4058
    npm ERR! enoent ENOENT: no such file or directory, rename 'D:\WorkSpace\wwwroot\gitHub\blog-code\themes\yilia\node_modules\_align-text@0.1.4@align-text\node_modules\repeat-string' -> '
    D:\WorkSpace\wwwroot\gitHub\blog-code\themes\yilia\node_modules\_align-text@0.1.4@align-text\node_modules\repeat-string'
    npm ERR! enoent This is related to npm not being able to find a file.
    npm ERR! enoent
    
    npm ERR! A complete log of this run can be found in:
    npm ERR!     D:\Program\Coding\NodeJs\node_cache\_logs\2021-04-09T14_43_11_839Z-debug.log
    
    
    npm ERR! code ELIFECYCLE
    npm ERR! errno 1
    npm ERR! node-sass@3.13.1 postinstall: `node scripts/build.js`
    npm ERR! Exit status 1
    npm ERR!
    npm ERR! Failed at the node-sass@3.13.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!     D:\Program\Coding\NodeJs\node_cache\_logs\2021-04-09T15_59_46_311Z-debug.log
    

    相关文章

      网友评论

          本文标题:windows下npm install报错node-sass无法

          本文链接:https://www.haomeiwen.com/subject/ilcgkltx.html