在使用 npm 版本3.8.x安装Ghost期间,会出现以下错误:
npm WARN optional Skipping failed optional dependency /chokidar/fsevents:
npm WARN notsup Not compatible with your operating system or architecture: fsevents@1.0.8
npm WARN Gonzah@0.0.1 No repository field.
npm ERR! Windows_NT 10.0.10586
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\aosman\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js" "install" "ghost"
npm ERR! node v4.3.2
npm ERR! npm v3.8.1
npm ERR! path D:\elastc-app\node_modules\ghost
npm ERR! code EPERM
npm ERR! errno -4048
npm ERR! syscall rename
npm ERR! Error: EPERM: operation not permitted, rename 'D:\elastc-app\node_modules\ghost' -> 'D:\elastc-app\node_modules\.ghost.DELETE'
npm ERR! at moveAway (C:\Users\aosman\AppData\Roaming\npm\node_modules\npm\lib\install\action\finalize.js:38:5)
npm ERR! at destStatted (C:\Users\aosman\AppData\Roaming\npm\node_modules\npm\lib\install\action\finalize.js:27:7)
npm ERR! at FSReqWrap.oncomplete (fs.js:82:15)
npm ERR!
npm ERR! Error: EPERM: operation not permitted, rename 'D:\elastc-app\node_modules\ghost' -> 'D:\elastc-app\node_modules\.ghost.DELETE'
npm ERR! at Error (native)
npm ERR! { [Error: EPERM: operation not permitted, rename 'D:\elastc-app\node_modules\ghost' -> 'D:\elastc-app\node_modules\.ghost.DELETE'] parent: 'Gonzah' }
npm ERR!
npm ERR! Please try running this command again as root/Administrator.
npm ERR! Please include the following file with any support request:
npm ERR! D:\elastc-app\npm-debug.log
在搜索了一天之后,它显然与npm v3.8(https://github.com/npm/npm/issues/10379#issuecomment-163316532)中的已知错误有关。
答案 0 :(得分:0)
解决方案是暂时将npm降级为v2 以执行安装。这样做:
<?php
header('Content-Type: text/html; charset=utf-8');
include ('simple_html_dom.php');
$mycache_url = 'http://example3.com';
$mybziran_url = 'http://example2.com';
function addhttp($url)
{
if (!preg_match("~^(?:f|ht)tps?://~i", $url)) {
global $mybziran_url;
$url = ltrim($url, '/');
$url = $mybziran_url . '/' . $url;
}
return $url;
}
function urlencodeproblem($badurl)
{
$badurl = urlencode($badurl);
$badchar = array('%3A', '%2F');
$truechar = array(':', '/');
$badurl = str_replace($badchar, $truechar, $badurl);
return $badurl;
}
$url_html = @file_get_html($mycache_url);
$bziran_url = '';
$bziran_title = '';
foreach (@$url_html->find('a') as $elements) {
$bziran_url[] = urlencodeproblem($elements->href);
$bziran_title[] = $elements->innertext;
}
$myi = count($bziran_url);
for ($i = 0; $i < $myi; ++$i) {
$post_title = $bziran_title[$i];
$post_url = $bziran_url[$i];
$html = @file_get_html($post_url);
foreach ($html->find('div.price') as $myhtml_price_adelete) {
echo '######' . $myhtml_price_adelete->innertext . '######';
}
$bad_title_my = '';
foreach ($html->find('h1 a') as $myhtml_price_adelete) {
$bad_title_my .= $myhtml_price_adelete->innertext;
}
if (empty($bad_title_my)) {
echo $post_url;
echo 'prob';
} else {
$kalame = urlencode($post_title);
$A2_html = 'ok';
foreach ($html->find('a') as $myhtml_a_code) {
$e_ahref = addhttp($myhtml_a_code->href);
$myhtml_a_code->href = $e_ahref;
$myhtml_a_code->target = '_blank';
}
$html->save();
foreach ($html->find('img') as $myhtml_img_code) {
if (strpos($myhtml_img_code->src, 'base64') === false) {
$e_imgsrc = addhttp($myhtml_img_code->src);
$myhtml_img_code->src = $e_imgsrc;
}
}
$html->save();
$mymeta_keyword = '';
foreach ($html->find('meta[name=keywords]') as $myhtml_keyword) {
$mymeta_keyword[] = $myhtml_keyword->content;
}
foreach ($html->find('p') as $mytagdelete) {
if (strpos($mytagdelete->innertext, 'tag :') !== false) {
$mytagdelete->outertext = '';
}
}
$html->save();
foreach ($html->find('h1 a') as $myadelete) {
$myadelete->outertext = $myadelete->innertext;
}
$html->save();
$a3_href = '';
$a2_href = $html->find("img[alt=buy]");
foreach ($a2_href as $a2_href) {
$a2_href->outertext =
'<br><p align="center"><img alt="pay-download" src="http://exam.com/tmp_files/01-pay-download.png"></p>';
}
$html->save();
echo '<br>buy : ' . $a3_href . '<br>';
$myhtmlcode3 = '';
foreach ($html->find('div.prod') as $myhtmlcode) {
$myhtmlcode3 .= $myhtmlcode->outertext;
}
$html->save();
echo '<br>*** title ***' . $post_title . '<br>';
echo $post_url . '<br>';
$i_t = mt_rand(1, 34);
$mysaier_mahsolat = '<br>
<a target="_blank" href="http://ayta.ir/index.php?page=' . $i_t . '"> click </a>
<br>';
echo $mysaier_mahsolat;
echo $A2_html . $myhtmlcode3 . '<br>';
echo 'keyword :' . $mymeta_keyword[0];
}
}
?>
<?
$crontest = date("Y-m-d - h:i:s") . "\n" . file_get_contents(dirname(__file__) .
DIRECTORY_SEPARATOR . "cron.txt");
echo $crontest;
file_put_contents("cron.txt", $crontest);
?>
然后当然可以再次将npm更新到最新版本。