[英]Why doesn't my Javascript file run?
"name": "javascript-development-environment",
"version": "1.0.0",
"description": "CS 235 package.json file for programming projects",
"scripts": {
"prestart": "babel-node buildScripts/startMessage.js",
"redditImgGet": "babel-node buildScripts/srcReddit.js",
"install": "npm install",
"start":"npm-run-all --parallel security-check open:src",
"security-check": "nsp check",
"open:src": "babel-node buildScripts/srcServer.js"
},
This is currently my package.json
. 当前是我的
package.json
。 I am trying to call the script which obtains an image from reddit . 我正在尝试调用从reddit获取图像的脚本。 The inside of
srcReddit.js
is shown below: srcReddit.js
的内部如下所示:
var snoowrap = require('snoowrap');
console.log("Starting Reddit Image Fetcher");
const otherRequester = new snoowrap({
userAgent: navigator.userAgent,
clientId: 'Cf8kGqDSuT17xw',
clientSecret: 'DDmMslUwMJW1ZM5JTc07zJDpC8k',
username: 'sharan100',
password: 'Magewindu100'
});
function getRandomInt(min, max) {
return Math.floor(Math.random() * (max - min + 1)) + min;
}
r.getHot().map(post => post.title).then(console.log);
console.log("Ending Reddit Image Fetcher");
For this, I am using the wrapper snoowrap for the reddit API . 为此,我使用reddit API的包装器snoowrap 。 Now when I do a
npm start
, I for some reason get this below: 现在,当我执行
npm start
,出于某种原因,请在下面获取此信息:
No idea why the console.log
messages do not appear. 不知道为什么
console.log
消息不出现。 Does anyone know why? 有人知道为什么吗?
npm start
runs the start
task and it does not refer to the redditImgGet
task at any time, it seems. npm start
运行start
任务,它似乎在任何时候都没有引用redditImgGet
任务。
I assume you should change your start
task to 我认为您应该将
start
任务更改为
npm-run-all --parallel security-check open:src redditImgGet
Or just run the task directly 或者直接运行任务
npm run redditImgGet
Otherwise, I don't see where you could expect the srcReddit
file to log anything. 否则,我看不到期望
srcReddit
文件记录任何内容的位置。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.